docs/v3/api-ref/python/prefect-infrastructure-provisioners-container_instance.mdx
prefect.infrastructure.provisioners.container_instanceThis module defines the ContainerInstancePushProvisioner class, which is responsible for provisioning infrastructure using Azure Container Instances for Prefect work pools.
The ContainerInstancePushProvisioner class provides methods for provisioning infrastructure and interacting with Azure Container Instances.
Classes: AzureCLI: A class to handle Azure CLI commands. ContainerInstancePushProvisioner: A class for provisioning infrastructure using Azure Container Instances.
AzureCLI <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/container_instance.py#L46" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>A class for executing Azure CLI commands and handling their output.
Args:
console: A Rich console object for displaying messages.Methods:
run_command <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/container_instance.py#L61" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>run_command(self, command: str, success_message: Optional[str] = None, failure_message: Optional[str] = None, ignore_if_exists: bool = False, return_json: bool = False) -> str | dict[str, Any] | None
Runs an Azure CLI command and processes the output.
Args:
command: The Azure CLI command to execute.success_message: Message to print on success.failure_message: Message to print on failure.ignore_if_exists: Whether to ignore errors if a resource already exists.return_json: Whether to return the output as JSON.Returns:
Raises:
subprocess.CalledProcessError: If the command execution fails.json.JSONDecodeError: If output cannot be decoded as JSON when return_json is True.ContainerInstancePushProvisioner <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/container_instance.py#L129" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>A class responsible for provisioning Azure resources and setting up a push work pool.
Attributes:
_console: A Rich console object for displaying messages and progress._subscription_id: Azure subscription ID._subscription_name: Azure subscription name._resource_group: Azure resource group name._location: Azure resource location.azure_cli: An instance of AzureCLI for running Azure commands.Methods:
console <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/container_instance.py#L167" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>console(self) -> Console
console <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/container_instance.py#L171" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>console(self, value: Console) -> None
provision <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/container_instance.py#L860" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>provision(self, work_pool_name: str, base_job_template: Dict[str, Any], client: Optional['PrefectClient'] = None) -> Dict[str, Any]
Orchestrates the provisioning of Azure resources and setup for the push work pool.
Args:
work_pool_name: The name of the work pool.base_job_template: The base template for job creation.client: An instance of PrefectClient. If None, it will be injected.Returns:
Raises:
RuntimeError: If client injection fails or the Azure CLI command execution fails.set_location <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/infrastructure/provisioners/container_instance.py#L174" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>set_location(self) -> None
Set the Azure resource deployment location to the default or 'eastus' on failure.
Raises:
RuntimeError: If unable to execute the Azure CLI command.