Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Astronomer Astronomer cosmos Azure Container Instance Operators

From Leeroopedia
Revision as of 14:29, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Astronomer_Astronomer_cosmos_Azure_Container_Instance_Operators.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Knowledge Sources
Domains Azure, ACI, Operators
Last Updated 2026-02-07 17:00 GMT

Overview

Provides Airflow operators for executing dbt commands on Azure Container Instances (ACI) by combining the Cosmos abstract dbt interface with Airflow's native AzureContainerInstancesOperator.

Description

The Azure_Container_Instance_Operators module defines DbtAzureContainerInstanceBaseOperator, which inherits from both AbstractDbtBase and AzureContainerInstancesOperator. This dual inheritance pattern mirrors the approach used by the ECS operators: the Cosmos abstract layer builds the dbt CLI command and profile configuration, while the Azure Container Instances operator handles provisioning a container group, injecting the command and environment, and streaming logs back to Airflow.

The base operator accepts Azure-specific parameters such as the resource group, container instance name, Docker image, and region. It also supports container registry authentication through a separate registry_conn_id and provides lifecycle controls like remove_on_error and fail_if_exists for managing ephemeral container groups.

Nine concrete operator classes extend the base, covering dbt sub-commands: build, ls, seed, snapshot, source freshness, run, test, run-operation, and clone. Each sets its own ui_color and ui_fgcolor for the Airflow graph view.

Usage

Use the Azure Container Instance operators when running dbt workloads on Azure without a dedicated Kubernetes cluster. ACI provides a serverless container execution model that is well-suited for short-lived dbt jobs where you do not need persistent infrastructure. This is a good choice for teams on Azure who want container-level isolation and resource control without the overhead of managing AKS clusters.

Code Reference

Source Location

Signature

class DbtAzureContainerInstanceBaseOperator(AbstractDbtBase, AzureContainerInstancesOperator):
    """
    Base class for running dbt commands on Azure Container Instances.
    """

    def __init__(
        self,
        ci_conn_id: str,
        resource_group: str,
        name: str,
        image: str,
        region: str,
        profile_config: ProfileConfig | None = None,
        remove_on_error: bool = True,
        fail_if_exists: bool = False,
        registry_conn_id: str | None = None,
        **kwargs,
    ) -> None:
        ...

Concrete operators:

class DbtBuildAzureContainerInstanceOperator(DbtAzureContainerInstanceBaseOperator): ...
class DbtLSAzureContainerInstanceOperator(DbtAzureContainerInstanceBaseOperator): ...
class DbtSeedAzureContainerInstanceOperator(DbtAzureContainerInstanceBaseOperator): ...
class DbtSnapshotAzureContainerInstanceOperator(DbtAzureContainerInstanceBaseOperator): ...
class DbtSourceAzureContainerInstanceOperator(DbtAzureContainerInstanceBaseOperator): ...
class DbtRunAzureContainerInstanceOperator(DbtAzureContainerInstanceBaseOperator): ...
class DbtTestAzureContainerInstanceOperator(DbtAzureContainerInstanceBaseOperator): ...
class DbtRunOperationAzureContainerInstanceOperator(DbtAzureContainerInstanceBaseOperator): ...
class DbtCloneAzureContainerInstanceOperator(DbtAzureContainerInstanceBaseOperator): ...

Import

from cosmos.operators.azure_container_instance import DbtRunAzureContainerInstanceOperator

I/O Contract

Inputs

Name Type Required Description
ci_conn_id str Yes Airflow connection ID for Azure credentials used to manage container instances.
resource_group str Yes The Azure resource group in which the container instance will be created.
name str Yes The name assigned to the Azure Container Instance.
image str Yes The Docker image to use for the container instance (e.g., "myregistry.azurecr.io/dbt:latest").
region str Yes The Azure region where the container instance will be provisioned.
profile_config ProfileConfig or None No Cosmos ProfileConfig object defining the dbt profile and target to use.
remove_on_error bool No Whether to remove the container group if the task fails. Defaults to True.
fail_if_exists bool No Whether to fail if a container group with the same name already exists. Defaults to False.
registry_conn_id str or None No Airflow connection ID for authenticating with a private container registry.

Outputs

Name Type Description
container_group_name str The name of the Azure Container Instance group that was created.
log_output str Standard output and error from the dbt command, captured from the container logs.

Usage Examples

from cosmos.operators.azure_container_instance import DbtRunAzureContainerInstanceOperator

run_dbt = DbtRunAzureContainerInstanceOperator(
    task_id="dbt_run_on_aci",
    ci_conn_id="azure_default",
    resource_group="rg-analytics",
    name="dbt-run-instance",
    image="myregistry.azurecr.io/dbt:latest",
    region="eastus",
    registry_conn_id="azure_acr",
)
from cosmos.operators.azure_container_instance import DbtTestAzureContainerInstanceOperator

test_dbt = DbtTestAzureContainerInstanceOperator(
    task_id="dbt_test_on_aci",
    ci_conn_id="azure_default",
    resource_group="rg-analytics",
    name="dbt-test-instance",
    image="myregistry.azurecr.io/dbt:latest",
    region="eastus",
    remove_on_error=True,
)

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment