Prefect integrations with Microsoft Azure services
Project description
prefect-azure
prefect-azure is a collection of Prefect integrations for orchestration workflows with Azure.
Getting Started
Installation
Install prefect-azure with pip
pip install prefect-azure
To use Blob Storage:
pip install "prefect-azure[blob_storage]"
To use Cosmos DB:
pip install "prefect-azure[cosmos_db]"
To use ML Datastore:
pip install "prefect-azure[ml_datastore]"
Examples
Download a blob
from prefect import flow
from prefect_azure import AzureBlobStorageCredentials
from prefect_azure.blob_storage import blob_storage_download
@flow
def example_blob_storage_download_flow():
connection_string = "connection_string"
blob_storage_credentials = AzureBlobStorageCredentials(
connection_string=connection_string,
)
data = blob_storage_download(
blob="prefect.txt",
container="prefect",
azure_credentials=blob_storage_credentials,
)
return data
example_blob_storage_download_flow()
Use with_options to customize options on any existing task or flow:
custom_blob_storage_download_flow = example_blob_storage_download_flow.with_options(
name="My custom task name",
retries=2,
retry_delay_seconds=10,
)
Run a command on an Azure container instance
from prefect import flow
from prefect_azure import AzureContainerInstanceCredentials
from prefect_azure.container_instance import AzureContainerInstanceJob
@flow
def container_instance_job_flow():
aci_credentials = AzureContainerInstanceCredentials.load("MY_BLOCK_NAME")
container_instance_job = AzureContainerInstanceJob(
aci_credentials=aci_credentials,
resource_group_name="azure_resource_group.example.name",
subscription_id="<MY_AZURE_SUBSCRIPTION_ID>",
command=["echo", "hello world"],
)
return container_instance_job.run()
Use Azure Container Instance as infrastructure
If we have a_flow_module.py:
from prefect import flow
from prefect.logging import get_run_logger
@flow
def log_hello_flow(name="Marvin"):
logger = get_run_logger()
logger.info(f"{name} said hello!")
if __name__ == "__main__":
log_hello_flow()
We can run that flow using an Azure Container Instance, but first create the infrastructure block:
from prefect_azure import AzureContainerInstanceCredentials
from prefect_azure.container_instance import AzureContainerInstanceJob
container_instance_job = AzureContainerInstanceJob(
aci_credentials=AzureContainerInstanceCredentials.load("MY_BLOCK_NAME"),
resource_group_name="azure_resource_group.example.name",
subscription_id="<MY_AZURE_SUBSCRIPTION_ID>",
)
container_instance_job.save("aci-dev")
Then, create the deployment either on the UI or through the CLI:
prefect deployment build a_flow_module.py:log_hello_flow --name aci-dev -ib container-instance-job/aci-dev
Visit Prefect Deployments for more information about deployments.
Azure Container Instance Worker
The Azure Container Instance worker is an excellent way to run your workflows on Azure.
To get started, create an Azure Container Instances typed work pool:
prefect work-pool create -t azure-container-instance my-aci-work-pool
Then, run a worker that pulls jobs from the work pool:
prefect worker start -n my-aci-worker -p my-aci-work-pool
The worker should automatically read the work pool's type and start an Azure Container Instance worker.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file prefect_azure-0.4.9.tar.gz.
File metadata
- Download URL: prefect_azure-0.4.9.tar.gz
- Upload date:
- Size: 59.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f765d6e3fc4b41d3b917986023f6c0fe445a4467e5a2637470714eda0e4d1982
|
|
| MD5 |
b14fa91bf26bfb9295bb5eab87349670
|
|
| BLAKE2b-256 |
73c535c41d6c186efd35a2c33fb678c6c0fa2d66363ec961a329cdfacad67e6d
|
Provenance
The following attestation bundles were made for prefect_azure-0.4.9.tar.gz:
Publisher:
integration-package-release.yaml on PrefectHQ/prefect
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
prefect_azure-0.4.9.tar.gz -
Subject digest:
f765d6e3fc4b41d3b917986023f6c0fe445a4467e5a2637470714eda0e4d1982 - Sigstore transparency entry: 946020497
- Sigstore integration time:
-
Permalink:
PrefectHQ/prefect@ee531648b970b255057701acb167c2882c297ea1 -
Branch / Tag:
refs/tags/prefect-azure-0.4.9 - Owner: https://github.com/PrefectHQ
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
integration-package-release.yaml@ee531648b970b255057701acb167c2882c297ea1 -
Trigger Event:
push
-
Statement type:
File details
Details for the file prefect_azure-0.4.9-py3-none-any.whl.
File metadata
- Download URL: prefect_azure-0.4.9-py3-none-any.whl
- Upload date:
- Size: 42.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7728e2d3078e41fa04efc2c82fa9b09ce0892379b7ce599465d3d9b50edf4e2c
|
|
| MD5 |
7cb17c93433f46db181b062a03ffae22
|
|
| BLAKE2b-256 |
af8ad0a319a6b0aea9db8b87c2ccb1e3bc89981bd8e4a4bbf57d7ada24327a02
|
Provenance
The following attestation bundles were made for prefect_azure-0.4.9-py3-none-any.whl:
Publisher:
integration-package-release.yaml on PrefectHQ/prefect
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
prefect_azure-0.4.9-py3-none-any.whl -
Subject digest:
7728e2d3078e41fa04efc2c82fa9b09ce0892379b7ce599465d3d9b50edf4e2c - Sigstore transparency entry: 946020539
- Sigstore integration time:
-
Permalink:
PrefectHQ/prefect@ee531648b970b255057701acb167c2882c297ea1 -
Branch / Tag:
refs/tags/prefect-azure-0.4.9 - Owner: https://github.com/PrefectHQ
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
integration-package-release.yaml@ee531648b970b255057701acb167c2882c297ea1 -
Trigger Event:
push
-
Statement type: