Python Microsoft Fabric tutorial

Entra app registration, the first Fabric connection and the three levels of the API.

This tutorial walks you through your first Microsoft Fabric integration with Zato - from creating the Entra app registration to making the first API call from a Python service.

Step 1 - Register the Entra application

Fabric authenticates through Entra ID, so the connection needs an app registration:

  1. In the Azure portal, go to Microsoft Entra ID → App registrations and click "New registration"
  2. Give it a name, e.g. Zato Fabric, and register it
  3. Note down the "Application (client) ID" and the "Directory (tenant) ID" from the overview page
  4. Under Certificates and secrets, create a new client secret and note down its value
  5. In the Fabric admin portal, under Tenant settings → Developer settings, enable "Service principals can use Fabric APIs"
  6. Add the service principal to the workspaces it should access - in each workspace, use Manage access and grant it the role your scenario requires, e.g. Contributor

Step 2 - Create the connection

Open the Dashboard and go to Cloud → Microsoft Fabric. Click "Create a new connection" and fill in the form:

FieldValue
NameMy Fabric
Addresshttps://api.fabric.microsoft.com/v1
Tenant IDThe directory (tenant) ID from step 1
Client IDThe application (client) ID from step 1
Client secretThe client secret from step 1

You can now click "Ping" to confirm that everything works - it obtains a token and lists the workspaces the principal has access to.

Step 3 - Make the first API call

Create a service that lists the workspaces the connection can see:

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

# Zato
from zato.server.service import Service

class ListMyWorkspaces(Service):

    def handle(self):

        # Get the connection by its Dashboard name
        conn = self.microsoft.fabric['My Fabric']

        # List all the workspaces
        response = conn.list_workspaces()

        # Extract their names
        names = [workspace['displayName'] for workspace in response['value']]

        self.response.payload = {'workspaces': names}

Hot-deploy the service and invoke it - the response contains the names of your Fabric workspaces.

Step 4 - Understand the API

There are three levels to the connection's API, and all of them share the same automatically managed Entra ID token:

Convenience methods - the operations most integrations need, one call each:

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

workspaces = conn.list_workspaces()
items = conn.list_items('12345678-1234-1234-1234-123456789abc')
conn.run_job('12345678-1234-1234-1234-123456789abc', 'item-id', 'RunNotebook')

Generic HTTP methods - conn.get, conn.post, conn.patch and conn.delete reach any Fabric endpoint by its path:

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

items = conn.get('/workspaces/12345678-1234-1234-1234-123456789abc/items')

The invoke method - conn.invoke(method, path, params, data) is what everything else builds on, for full control:

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

result = conn.invoke('GET', '/workspaces', params={'roles': 'Admin'})

Tokens are acquired on first use, cached, refreshed before they expire, and re-acquired transparently if the API ever rejects one - your code never handles them. The OneLake data plane uses a second, storage-scoped token which is managed the same way.

Step 5 - Explore the topics

With the connection in place, the pages below cover the most common integrations with complete examples:

  • Workspaces - listing, creating and managing workspaces
  • Lakehouses - lakehouse items, loading data, tables and files
  • Notebooks - running Spark notebooks on demand
  • Pipelines - Data Factory pipeline runs, monitoring and cancellation
  • Data science - ML models and experiments
  • Reports - Power BI reports and semantic models
  • OneLake - shortcuts plus reading and writing files through the data plane

More resources

Learn more