Python Microsoft Fabric tutorial

Entra app registration, the first Fabric connection, and loading and querying the first table.

This tutorial walks you through your first Microsoft Fabric integration with Zato - from creating the Entra app registration to loading and querying your first lakehouse table 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 - Load and query a table

Create a service that writes rows to a lakehouse table and reads them back with SQL:

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

# Zato
from zato.server.service import Service

class LoadAndQuery(Service):

    input = 'workspace_id', 'lakehouse_id'

    def handle(self):

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

        # Write rows to a table ..
        rows = [
            {'region': 'EMEA', 'total': 1250.50},
            {'region': 'APAC', 'total': 875.25},
        ]
        conn.write_table(self.request.input.workspace_id, self.request.input.lakehouse_id, 'daily_totals', rows)

        # .. and query them back.
        result = conn.query(
            self.request.input.workspace_id,
            self.request.input.lakehouse_id,
            'select region, total from daily_totals',
        )

        self.response.payload = {'rows': result}

Under the hood, write_table uploads the rows as a CSV file to the lakehouse's Files section through OneLake, then tells the lakehouse to load that file into the table and waits until the load completes - the same upload-then-load steps you can run yourself with onelake_write and load_table.

Hot-deploy the service and invoke it - the response contains the rows the table now holds. The Tables page covers loading files, bulk loads and everything else around tables and queries.

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')
job_id = 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.

See also

PageWhat it covers
TablesLoading rows and files into lakehouse tables and querying them with SQL
LakehousesLakehouse items, loading data, tables and files
OneLakeShortcuts plus reading and writing files through the data plane
WorkspacesListing, creating and managing workspaces
NotebooksRunning Spark notebooks on demand
PipelinesData Factory pipeline runs, monitoring and cancellation
Data scienceML models and experiments
ReportsPower BI reports and semantic models

Learn more