Python Microsoft Fabric API - Jobs

run_job, get_job and cancel_job, the job types for notebooks, pipelines and report refreshes, and the statuses.

Running a notebook, running a pipeline and refreshing a report's data are all jobs in Fabric, started, checked and cancelled with the same three methods. Every one takes the workspace ID and the ID of the item the job belongs to.

Job types

ItemJob typeWhat it does
NotebookRunNotebookRuns the notebook once
PipelinePipelineRuns the pipeline once
A report's datasetDefaultSemanticModelRefreshRefreshes the report's data from the tables it reads

Statuses

get_job reports one of these in status:

StatusMeaning
NotStartedAccepted, not yet running
InProgressRunning
CompletedEnded without error
FailedEnded with an error, details in failureReason
CancelledStopped with cancel_job or from Fabric
DedupedNot started, because the same job was already running

The first two mean the job is still going, everything else means it has ended.

run_job

conn.run_job(workspace_id, item_id, job_type, payload=None)

Starts a job and returns as soon as Fabric has accepted it, without waiting for it to run.

ParameterTypeMeaning
workspace_idstrThe workspace the item is in
item_idstrThe notebook, pipeline or dataset
job_typestrOne of the job types above
payloaddictParameters for the job, or none

Returns the job's ID as a string, for get_job and cancel_job.

Parameters travel under executionData. A notebook takes them for its parameter cell, each with a value and a type, a pipeline takes them as plain values:

# -*- coding: utf-8 -*-

# Zato
from zato.server.service import Service

class RunNotebook(Service):

    def handle(self):

        workspace_id = '11111111-2222-3333-4444-555555555555'
        notebook_id = 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'

        conn = self.microsoft.fabric['My Fabric']

        payload = {
            'executionData': {
                'parameters': {
                    'location': {'value': 'Riverside', 'type': 'string'},
                    'days_ahead': {'value': '1', 'type': 'int'},
                }
            }
        }

        job_id = conn.run_job(workspace_id, notebook_id, 'RunNotebook', payload)

        self.response.payload = {'job_id': job_id}
payload = {
    'executionData': {
        'parameters': {
            'source_table': 'admissions',
            'target_table': 'occupancy',
        }
    }
}

job_id = conn.run_job(workspace_id, pipeline_id, 'Pipeline', payload)

A report refresh takes no parameters:

job_id = conn.run_job(workspace_id, dataset_id, 'DefaultSemanticModelRefresh')

get_job

conn.get_job(workspace_id, item_id, job_id)

Returns the job's current state.

ParameterTypeMeaning
workspace_idstrThe workspace the item is in
item_idstrThe item the job belongs to
job_idstrThe ID run_job returned

Returns a dict with id, itemId, jobType, invokeType, status, startTimeUtc, endTimeUtc and, for a failed job, failureReason.

# -*- coding: utf-8 -*-

# Zato
from zato.server.service import Service

class GetJob(Service):

    def handle(self):

        workspace_id = '11111111-2222-3333-4444-555555555555'
        item_id = 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'
        job_id = 'dddddddd-eeee-ffff-0000-111111111111'

        conn = self.microsoft.fabric['My Fabric']

        job = conn.get_job(workspace_id, item_id, job_id)

        self.response.payload = {'status': job['status'], 'started': job['startTimeUtc'], 'ended': job['endTimeUtc']}
{"status": "Completed", "started": "2026-03-12T02:30:04Z", "ended": "2026-03-12T02:34:11Z"}

cancel_job

conn.cancel_job(workspace_id, item_id, job_id)

Asks Fabric to stop a running job. Returns nothing, and the job's status becomes Cancelled once it has stopped, which get_job shows.

ParameterTypeMeaning
workspace_idstrThe workspace the item is in
item_idstrThe item the job belongs to
job_idstrThe ID run_job returned
# -*- coding: utf-8 -*-

# Zato
from zato.server.service import Service

class CancelJob(Service):

    def handle(self):

        workspace_id = '11111111-2222-3333-4444-555555555555'
        item_id = 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'
        job_id = 'dddddddd-eeee-ffff-0000-111111111111'

        conn = self.microsoft.fabric['My Fabric']

        conn.cancel_job(workspace_id, item_id, job_id)

See also

PageWhat it covers
Picking up results when a notebook finishesrun_job and get_job across two scheduled services
Running a pipeline and refreshing a reportAll three methods in one service, with a timeout
WorkspacesFinding the item IDs the jobs need

Learn more