> For the complete CircleCI developer hub index, see [llms.txt](https://circleci.com/developer/llms.txt)

# circleci/azure-cli

Install, initialize, and log into the Azure command-line interface (azcli)


## Commands

### install

Install the Azure CLI, if not available


### login-with-service-principal

Initilize the Azure CLI

| Parameter | Type | Default | Description |
|---|---|---|---|
| `azure-sp` | env_var_name | AZURE_SP | Name of environment variable storing the full name of the Service Principal, in the form http://app-url
 |
| `azure-sp-password` | env_var_name | AZURE_SP_PASSWORD | Name of environment variable storing the password for the Service Principal
 |
| `azure-sp-tenant` | env_var_name | AZURE_SP_TENANT | Name of environment variable storing the tenant ID for the Service Principal
 |

### login-with-user

Initilize the Azure CLI

| Parameter | Type | Default | Description |
|---|---|---|---|
| `alternate-tenant` | boolean | false | Use an alternate tenant |
| `azure-password` | env_var_name | AZURE_PASSWORD | Environment variable storing your Azure password
 |
| `azure-tenant` | env_var_name | AZURE_TENANT | Environment variable storing your Azure tenant, necessary if `alternate-tenant` is set to true
 |
| `azure-username` | env_var_name | AZURE_USERNAME | Environment variable storing your Azure username
 |

### login-with-user-or-service-principal

Initilize the Azure CLI. Supports login either with a user or with a Service Principal. The type of login is determined by checking if the environment variable storing the Azure username or the environment variable storing the name of the Service Principal is set to a non-empty value.


| Parameter | Type | Default | Description |
|---|---|---|---|
| `alternate-tenant` | boolean | false | Use an alternate tenant. Only applicable for user logins. |
| `azure-password` | env_var_name | AZURE_PASSWORD | Environment variable storing your Azure password. Only applicable for user logins.
 |
| `azure-sp` | env_var_name | AZURE_SP | Name of environment variable storing the full name of the Service Principal, in the form http://app-url. Only applicable for Service Principal logins.
 |
| `azure-sp-password` | env_var_name | AZURE_SP_PASSWORD | Name of environment variable storing the password for the Service Principal. Only applicable for Service Principal logins.
 |
| `azure-sp-tenant` | env_var_name | AZURE_SP_TENANT | Name of environment variable storing the tenant ID for the Service Principal. Only applicable for Service Principal logins.
 |
| `azure-tenant` | env_var_name | AZURE_TENANT | Environment variable storing your Azure tenant, necessary if `alternate-tenant` is set to true. Only applicable for user logins.
 |
| `azure-username` | env_var_name | AZURE_USERNAME | Environment variable storing your Azure username. Only applicable for user logins.
 |

## Executors

### azure-docker

Microsoft's Azure CLI Docker image


| Parameter | Type | Default | Description |
|---|---|---|---|
| `tag` | string | latest | The microsoft azure cli Docker image version tag. |

### default

CircleCI official cimg/python Docker image to use


| Parameter | Type | Default | Description |
|---|---|---|---|
| `python-version` | string | 3.12.9 |  |

## Examples

### install

Install the Azure CLI


```yaml
version: '2.1'
orbs:
  azure-cli: circleci/azure-cli@1.0.0
jobs:
  verify-install:
    executor: azure-cli/default
    steps:
      - azure-cli/install
      - run:
          command: az -v
          name: Verify Azure CLI is installed
workflows:
  example-workflow:
    jobs:
      - verify-install
```

### login-with-service-principal

Log into Azure with a Service Principal


```yaml
version: '2.1'
orbs:
  azure-cli: circleci/azure-cli@1.0.0
jobs:
  login-to-azure:
    executor: azure-cli/azure-docker
    steps:
      - azure-cli/login-with-service-principal
      - run:
          command: az resource list
          name: List resources of tenant stored as `AZURE_SP_TENANT` env var
workflows:
  example-workflow:
    jobs:
      - login-to-azure
```

### login-with-user

Install the Azure CLI, then log in with a username and password


```yaml
version: '2.1'
orbs:
  azure-cli: circleci/azure-cli@1.0.0
jobs:
  login-to-azure:
    executor: azure-cli/default
    steps:
      - azure-cli/install
      - azure-cli/login-with-user:
          alternate-tenant: true
      - run:
          command: az resource list
          name: List resources of tenant stored as `AZURE_TENANT` env var
workflows:
  example-workflow:
    jobs:
      - login-to-azure
```

### login-with-user-or-service-principal

Log into Azure with the login type determined based on environment variable detection.


```yaml
version: '2.1'
orbs:
  azure-cli: circleci/azure-cli@1.0.0
jobs:
  login-to-azure:
    executor: azure-cli/azure-docker
    steps:
      - azure-cli/login-with-user-or-service-principal
      - run:
          command: az resource list
          name: List resources of tenant stored as `AZURE_SP_TENANT` env var
workflows:
  example-workflow:
    jobs:
      - login-to-azure
```