Skip to main content

atmos.azure

The atmos.azure function runs atmos azure through the current Atmos executable. Use it to configure AKS kubeconfig files and log in to Azure Container Registry from automation.

Usage​

atmos.azure(
*positionals,
flags = {},
args = [],
working_directory = ...,
env = ...,
output = "stream",
check = True,
)

Subcommands​

Pass the subcommand group, its nested subcommand, and any positional arguments as strings before the keyword arguments. The call atmos.azure("acr", "login", flags = {"identity": "dev"}) runs atmos azure acr login --identity=dev.

SubcommandPurpose
aks update-kubeconfigUpdate the kubeconfig for an AKS cluster.
aks tokenGenerate an AKS bearer token for kubectl.
acr loginLog in to Azure Container Registry and write Docker credentials.

See the atmos azure command reference for the complete list of subcommands and flags. The aks group has its own page.

Arguments​

*positionals

(Optional) Strings placed on the command line right after azure, in order: the subcommand group, the nested subcommand, and any positional arguments. Every value must be a string.

flags

(Optional) A dictionary of command-line options; see flag translation. A bare key such as "cluster-name" becomes --cluster-name, and registered shorthands resolve to their long form, so "i" resolves to --identity and "r" to --registry for acr login. Other flags include --resource-group, --subscription-id, and --kubeconfig for the aks commands.

args

(Optional) A list or tuple of strings appended after the flags. The azure command accepts a -- separator before arguments meant for the underlying tool.

working_directory, env, output, check

(Optional) See atmos.run for process options and defaults.

Options other than the positionals are keyword-only.

Returns​

A result with stdout, stderr, and exit_code. See atmos.run for output and error behavior.

Examples​

Configure kubectl for an AKS cluster​

atmos.azure(
"aks",
"update-kubeconfig",
flags = {
"cluster-name": "dev-aks",
"resource-group": "dev-rg",
"identity": "dev-admin",
},
)

This runs atmos azure aks update-kubeconfig --cluster-name=dev-aks --identity=dev-admin --resource-group=dev-rg.

Log in to a registry before a build​

atmos.azure("acr", "login", flags = {"identity": "dev-admin", "registry": ["devregistry.azurecr.io"]})

Handle a missing identity​

result = atmos.azure(
"aks",
"token",
flags = {"cluster-name": "dev-aks", "resource-group": "dev-rg"},
output = "capture",
check = False,
)
if result.exit_code != 0:
fail("Could not generate an AKS token:\n" + result.stderr)

Without an identity argument, the command falls back to the default identity and fails when none is configured.