Fabric API - Jobs

run_job, wait_for_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, and the four methods below start, wait for, check and cancel them. Each method 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 without waiting for it.

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 go under executionData. A notebook takes them with a value and a type each, a pipeline takes plain values:

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

# Zato
from zato.server.service import Service

class RunNotebook(Service):

    def handle(self):

        workspace_id = '262ddd3d-3d0d-4495-b80f-6dddda1e23a1'
        notebook_id = 'ba7b1e23-b680-4fe7-a982-2a979b125604'

        conn = self.microsoft.fabric['Zato 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')

wait_for_job

conn.wait_for_job(workspace_id, item_id, job_id, timeout=1800, interval=10.0)

Waits until a job ends and returns its final state, checking with get_job every interval seconds.

ParameterTypeMeaning
workspace_idstrThe workspace the item is in
item_idstrThe item the job belongs to
job_idstrThe ID run_job returned
timeoutintHow many seconds to wait at most, 30 minutes by default
intervalfloatHow many seconds between two checks, 10 by default

Returns the same dict as get_job once the status is Completed. A job that ends with any other status raises an exception with the job's details, and so does one that is still running when the timeout passes, the job itself keeps running in Fabric then.

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

# Zato
from zato.server.service import Service

class RunAndWait(Service):

    def handle(self):

        workspace_id = '262ddd3d-3d0d-4495-b80f-6dddda1e23a1'
        pipeline_id = 'bf4868aa-05c8-4213-ab4d-8dcbe3189767'

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

        job_id = conn.run_job(workspace_id, pipeline_id, 'Pipeline')
        job = conn.wait_for_job(workspace_id, pipeline_id, job_id, timeout=600)

        self.response.payload = {'status': job['status'], 'ended': job['endTimeUtc']}
{"status": "Completed", "ended": "2026-09-02T02:34:11Z"}

get_job

conn.get_job(workspace_id, item_id, job_id)

Returns the job's current state without waiting for it.

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):

    input = 'job_id'

    def handle(self):

        workspace_id = '262ddd3d-3d0d-4495-b80f-6dddda1e23a1'
        notebook_id = 'ba7b1e23-b680-4fe7-a982-2a979b125604'

        # The ID of a job that run_job returned earlier
        job_id = self.request.input.job_id

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

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

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

cancel_job

conn.cancel_job(workspace_id, item_id, job_id)

Stops a running job. Returns nothing, the job's status becomes Cancelled once it has stopped.

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):

    input = 'job_id'

    def handle(self):

        workspace_id = '262ddd3d-3d0d-4495-b80f-6dddda1e23a1'
        notebook_id = 'ba7b1e23-b680-4fe7-a982-2a979b125604'

        # The ID of a job that run_job returned earlier
        job_id = self.request.input.job_id

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

        conn.cancel_job(workspace_id, notebook_id, job_id)

See also

PageWhat it covers
Fabric notebooks and pipelinesrun_job and wait_for_job for a notebook, a pipeline and a report refresh
Fabric API - WorkspacesFinding the item IDs the jobs need

Learn more