prefect-azure makes it easy to leverage the capabilities of Azure in your workflows.
For example, you can retrieve secrets, read and write Blob Storage objects, and deploy your flows on Azure Container Instances (ACI).
Getting started
Prerequisites
- An Azure account and the necessary permissions to access desired services.
Install prefect-azure
The following command will install a version of prefect-azure compatible with your installed version of prefect.
If you don’t already have prefect installed, it will install the newest version of prefect as well.
prefect and prefect-azure:
Register newly installed block types
Register the block types in the module to make them available for use.Examples
Download a blob
with_options to customize options on any existing task or flow:
Using Service Principal Authentication
Azure Blob Storage credentials support Service Principal Name (SPN) authentication for secure access to your storage account.Example: SPN Authentication
Example: SPN Authentication
Create an Then reference this block in your When all three SPN fields (
AzureBlobStorageCredentials block with your service principal credentials:prefect.yaml deployment steps:tenant_id, client_id, client_secret) are provided, the credentials will use ClientSecretCredential for authentication. If any SPN fields are missing, it will fall back to DefaultAzureCredential.Run flows on Azure Container Instances
Run flows on Azure Container Instances (ACI) to dynamically scale your infrastructure. See the Azure Container Instances Worker Guide for a walkthrough of using ACI in a hybrid work pool. If you’re using Prefect Cloud, ACI push work pools provide all the benefits of ACI with a quick setup and no worker needed.Managed Identity Authentication for PostgreSQL (Experimental)
prefect-azure includes a plugin that authenticates the Prefect server to Azure Database for PostgreSQL using a Microsoft Entra ID token from a managed identity, so no database password is stored anywhere. The token is acquired via DefaultAzureCredential and supplied to the database driver on every new connection, so short-lived tokens are refreshed automatically.
Prerequisites
Before using managed identity authentication, configure Azure:- Enable Microsoft Entra authentication on your Azure Database for PostgreSQL flexible server.
-
Create a database principal for the identity and grant it access, using the
pgaadauthextension while connected as an Entra administrator: -
Make the identity available to the Prefect server — a user-assigned or system-assigned managed identity when running in Azure, or your
az loginidentity when developing locally (both are resolved byDefaultAzureCredential).
Enable the Plugin
-
Enable the plugin system:
-
Enable managed identity authentication:
-
(Optional) Select a specific user-assigned identity by client ID:
-
Configure a password-less database connection URL (the plugin supplies the token):
Resources
For assistance using Azure, consult the Azure documentation. Refer to the prefect-azure SDK Reference to explore all the capabilities of theprefect-azure library.
Additional installation options
First install the main library compatible with yourprefect version: