airflow.contrib.hooks.azure_container_instance_hook

Module Contents

class airflow.contrib.hooks.azure_container_instance_hook.AzureContainerInstanceHook(conn_id='azure_default')[source]

Bases:airflow.hooks.base_hook.BaseHook

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

get_conn(self)[source]
create_or_update(self, resource_group, name, container_group)[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, name)[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_instance_view(self, resource_group, name)[source]
get_messages(self, resource_group, name)[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_logs(self, resource_group, name, tail=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, name)[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, name)[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