Skip to main content

prefect_azure.container_instance

Integrations with the Azure Container Instances service. Note this module is experimental. The interfaces within may change without notice. The AzureContainerInstanceJob infrastructure block in this module is ideally configured via the Prefect UI and run via a Prefect agent, but it can be called directly as demonstrated in the following examples. Examples: Run a command using an Azure Container Instances container.
AzureContainerInstanceJob(command=["echo", "hello world"]).run()
Run a command and stream the container’s output to the local terminal.
AzureContainerInstanceJob(
    command=["echo", "hello world"],
    stream_output=True,
)
Run a command with a specific image
AzureContainerInstanceJob(command=["echo", "hello world"], image="alpine:latest")
Run a task with custom memory and CPU requirements
AzureContainerInstanceJob(command=["echo", "hello world"], memory=1.0, cpu=1.0)
Run a task with custom memory and CPU requirements
AzureContainerInstanceJob(command=["echo", "hello world"], memory=1.0, cpu=1.0)
Run a task with custom memory, CPU, and GPU requirements
AzureContainerInstanceJob(command=["echo", "hello world"], memory=1.0, cpu=1.0,
gpu_count=1, gpu_sku="V100")
Run a task with custom environment variables
AzureContainerInstanceJob(
    command=["echo", "hello $PLANET"],
    env={"PLANET": "earth"}
)
Run a task that uses a private ACR registry with a managed identity
AzureContainerInstanceJob(
    command=["echo", "hello $PLANET"],
    image="my-registry.azurecr.io/my-image",
    image_registry=ACRManagedIdentity(
        registry_url="my-registry.azurecr.io",
        identity="/my/managed/identity/123abc"
    )
)

Classes

ContainerGroupProvisioningState

Terminal provisioning states for ACI container groups. Per the Azure docs, the states in this Enum are the only ones that can be relied on as dependencies.

ContainerRunState

Terminal run states for ACI containers.

ACRManagedIdentity

Use a Managed Identity to access Azure Container registry. Requires the user-assigned managed identity be available to the ACI container group.

AzureContainerInstanceJobResult

The result of an AzureContainerInstanceJob run.