Python Microsoft Power Automate tutorial

Azure app registration, the first Power Automate connection and triggering your first flow.

This tutorial walks you through your first Power Automate integration with Zato - from creating the Azure app registration to triggering a flow from a Python service.

Step 1 - Register the Azure application

Power Automate authenticates through Azure AD, so the connection needs an app registration:

  1. In the Azure portal, go to Azure Active Directory → App registrations and click "New registration"
  2. Give it a name, e.g. Zato Power Automate, 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. Grant the application access to the Power Automate service - in API permissions, add the "Power Automate" (Microsoft Flow Service) permissions your scenario requires and have an administrator consent to them

You also need the ID of the Power Platform environment your flows live in - you can find it in the Power Platform admin center under Environments, e.g. Default-98765432-5432-5432-5432-dcba98765432.

Step 2 - Create the connection

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

FieldValue
NameMy Power Automate
Addresshttps://api.flow.microsoft.com
Tenant IDThe directory (tenant) ID from step 1
Client IDThe application (client) ID from step 1
Client secretThe client secret from step 1
Environment IDYour Power Platform environment ID

You can now click "Ping" to confirm that everything works - it obtains a token and lists the environment's flows.

Step 3 - Trigger the first flow

Create an instant flow in Power Automate with the "When an HTTP request is received" trigger, then trigger it from a service:

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

# Zato
from zato.server.service import Service

class TriggerFirstFlow(Service):

    def handle(self):

        # Get the connection by its Dashboard name
        conn = self.microsoft.power_platform['My Power Automate']

        # Trigger the flow, sending it a payload
        conn.trigger('flow-invoice-approval', {
            'invoice_id': 'INV-2026-0042',
            'amount': 1250.50,
        })

        self.response.payload = {'status': 'triggered'}

Hot-deploy the service and invoke it - the flow starts running in Power Automate with the payload your service sent.

Step 4 - Understand the API

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

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

conn = self.microsoft.power_platform['My Power Automate']

flows = conn.list_flows()
conn.trigger('flow-invoice-approval', {'invoice_id': 'INV-2026-0042'})
runs = conn.list_runs('flow-invoice-approval')

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

conn = self.microsoft.power_platform['My Power Automate']

path = '/providers/Microsoft.ProcessSimple/environments/my-environment/flows'
flows = conn.get(path)

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

conn = self.microsoft.power_platform['My Power Automate']

result = conn.invoke('GET', path, params={'$top': 10})

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.

Step 5 - Explore the topics

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

  • Triggering flows - instant flows, HTTP request triggers, payloads
  • Managing flows - listing, inspecting, enabling and disabling flows
  • Monitoring runs - run history, failures, cancelling and resubmitting
  • Approvals - starting approval flows and reacting to their outcomes
  • Teams - Teams notifications and adaptive cards through flows
  • SharePoint - SharePoint-driven flows, files and list items
  • Email - Outlook email automation through flows

More resources

Learn more