airflow.providers.microsoft.azure.hooks.azure_container_instance

Module Contents

class airflow.providers.microsoft.azure.hooks.azure_container_instance.AzureContainerInstanceHook(conn_id: str = default_conn_name)[source]

Bases: airflow.providers.microsoft.azure.hooks.base_azure.AzureBaseHook

A hook to communicate with Azure Container Instances.

This hook requires a service principal in order to work. After creating this service principal (Azure Active Directory/App Registrations), you need to fill in the client_id (Application ID) as login, the generated password as password, and tenantId and subscriptionId in the extra's field as a json.

Parameters

conn_id (str) -- connection id of a service principal which will be used to start the container instance

conn_name_attr = conn_id[source]
default_conn_name = azure_default[source]
conn_type = azure_container_instances[source]
hook_name = Azure Container Instance[source]
create_or_update(self, resource_group: str, name: str, container_group: ContainerGroup)[source]

Create a new container group

Parameters
  • resource_group (str) -- the name of the resource group

  • name (str) -- the name of the container group

  • container_group (azure.mgmt.containerinstance.models.ContainerGroup) -- the properties of the container group

get_state_exitcode_details(self, resource_group: str, name: str)[source]

Get the state and exitcode of a container group

Parameters
  • resource_group (str) -- the name of the resource group

  • name (str) -- the name of the container group

Returns

A tuple with the state, exitcode, and details. If the exitcode is unknown 0 is returned.

Return type

tuple(state,exitcode,details)

get_messages(self, resource_group: str, name: str)[source]

Get the messages of a container group

Parameters
  • resource_group (str) -- the name of the resource group

  • name (str) -- the name of the container group

Returns

A list of the event messages

Return type

list[str]

get_state(self, resource_group: str, name: str)[source]

Get the state of a container group

Parameters
  • resource_group (str) -- the name of the resource group

  • name (str) -- the name of the container group

Returns

ContainerGroup

Return type

ContainerGroup

get_logs(self, resource_group: str, name: str, tail: int = 1000)[source]

Get the tail from logs of a container group

Parameters
  • resource_group (str) -- the name of the resource group

  • name (str) -- the name of the container group

  • tail (int) -- the size of the tail

Returns

A list of log messages

Return type

list[str]

delete(self, resource_group: str, name: str)[source]

Delete a container group

Parameters
  • resource_group (str) -- the name of the resource group

  • name (str) -- the name of the container group

exists(self, resource_group: str, name: str)[source]

Test if a container group exists

Parameters
  • resource_group (str) -- the name of the resource group

  • name (str) -- the name of the container group

Was this entry helpful?