# Azure CLI

Azure CLI is Microsoft's cross-platform command-line tool for managing Azure resources from a terminal or script.

Cloud service · Azure. Updated 2026-11-30. Page: https://blowstack.com/tools/cloud-services-hub/azure-cli

> The `az` command lets engineers provision infrastructure, inspect resource state, and automate administrative tasks across Azure subscriptions. It supports Azure management operations and selected data-plane operations, such as uploading files to Azure Blob Storage.

## 8 key features of Azure CLI

1. **Cross-platform execution**: Run `az` on Windows, macOS, Linux, in Azure Cloud Shell, or in a container. Adapt quoting, variables, and line continuation to the shell that runs the script.
2. **Service-specific resource management**: Use groups such as `az vm`, `az network`, and `az storage` for service-specific tasks. Use `az resource` for generic Azure Resource Manager operations such as reading a resource by ID.
3. **Identity and subscription selection**: Use interactive Microsoft Entra sign-in for operators and workload identities for unattended jobs. Select the intended subscription explicitly when a script runs against multiple environments.
4. **Structured output and filtering**: Use `--query` to select fields with JMESPath and `--output json` to preserve nested results. Use `--output tsv` to capture a single resource ID or other scalar value in a script.
5. **Bicep and ARM template deployment**: Submit Bicep files and ARM templates through `az deployment` at the appropriate scope. Use a what-if operation to review predicted changes before submitting a deployment.
6. **Installable extensions**: Use `az extension` to install, inspect, update, or remove additional command groups. Pin required extensions in controlled runner environments and test their compatibility with the base CLI.
7. **Built-in help**: Append `--help` to a command or group to check the supported parameters and examples. This helps diagnose differences between the CLI installed on a workstation and the one installed on a build runner.
8. **Direct Azure API requests**: Use `az rest` to call an Azure API when a dedicated command does not cover the operation. For Azure Resource Manager requests, supply an API version supported by the resource provider and ensure the signed-in identity is authorized.

## Where Azure CLI is used

1. **Provision environments from version control**: Run a Bicep what-if check during pull request validation, then deploy the approved template with environment-specific parameters and an explicit subscription ID.
2. **Deploy and verify container releases**: Build an image in Azure Container Registry, update an Azure Container Apps deployment to reference it, and check the resulting revision before marking the release successful.
3. **Inventory resources across subscriptions**: Enumerate subscriptions visible to the signed-in identity and collect resource IDs, locations, and tags as structured output for reporting or governance checks.
4. **Investigate failed infrastructure changes**: Inspect Azure Activity Log entries and deployment operations to identify which resource failed and read the reported error before retrying or rolling back.
5. **Run scheduled administrative jobs**: Use a managed identity on a supported Azure host to check resource settings or write reports to Blob Storage without storing a user password or storage account key in the job.

## How Azure CLI is priced

- **No separate CLI charge**: Azure CLI is free to install and use. Azure resources managed through it and supporting services such as persistent Cloud Shell storage or hosted build runners are subject to their own pricing.

## Services Azure CLI works with

In infrastructure pipelines, use Azure CLI to submit version-controlled Bicep or ARM templates and verify the deployment. An Azure Pipelines job can authenticate through a federated Azure Resource Manager service connection, run what-if against the target scope, and deploy after approval. Specify the subscription and resource group explicitly so that the runner's defaults do not determine where changes are applied.

For a container release, build the image in Azure Container Registry, pass its reference to Azure Container Apps, and verify the new revision before shifting traffic in multiple-revision mode. A registry that requires authentication must accept the app's configured managed identity or registry credentials; an anonymously accessible image needs neither. When using managed identity, a dedicated pull identity makes it possible to grant the app pull access without also granting the pipeline's build and deployment permissions.

For scheduled operations, a managed identity can upload reports to Blob Storage and query logs in a designated Log Analytics workspace. Grant blob data permissions for the target container and the required query permissions for the logs separately. Management access to a resource does not by itself authorize every operation on the data it stores.

- **[Azure Resource Manager](https://blowstack.com/tools/cloud-services-hub/azure-resource-manager)**: Azure CLI submits Bicep and ARM template deployments through Azure Resource Manager. For example, run `az deployment group what-if` to review predicted changes in a resource group, then run `az deployment group create` after approval.
- **[Microsoft Entra ID (formerly Azure AD)](https://blowstack.com/tools/cloud-services-hub/microsoft-entra-id-(formerly-azure-ad))**: Azure CLI uses Microsoft Entra ID for interactive and workload authentication. For example, a script on an Azure VM can run `az login --identity` with the VM's system-assigned managed identity and inspect resource metadata with the Reader role scoped to the target resource group.
- **[Azure DevOps](https://blowstack.com/tools/cloud-services-hub/azure-devops)**: The Azure Pipelines `AzureCLI@2` task runs scripts using an Azure Resource Manager service connection. For example, configure the connection for workload identity federation and run a Bicep what-if check without storing a client secret.
- **[Azure Container Registry](https://blowstack.com/tools/cloud-services-hub/azure-container-registry)**: Use `az acr build` to build and push an image to Azure Container Registry, then use `az containerapp update --image` to deploy it to an existing app. For example, deploy an image tagged with the commit SHA and check the resulting revision. If the registry requires authentication, configure the app with a managed identity that has pull permission or with supported registry credentials; no pull credentials are needed for an image available anonymously. If using a managed identity for pulls, keeping it separate from the pipeline identity is a least-privilege recommendation, not a service requirement.
- **[Azure Blob Storage](https://blowstack.com/tools/cloud-services-hub/azure-blob-storage)**: Azure CLI can access blob data using Microsoft Entra authorization without retrieving storage account keys. For example, a reporting job can run `az storage blob upload --auth-mode login` to write a file to a container where its identity has the Storage Blob Data Contributor role.
- **[Azure Monitor](https://blowstack.com/tools/cloud-services-hub/azure-monitor)**: Use Azure CLI to configure diagnostic settings and query collected telemetry. For example, use `az monitor diagnostic-settings create` to route supported resource logs to a Log Analytics workspace, then run `az monitor log-analytics query` to verify that records arrive after ingestion.
- **[Azure Bastion](https://blowstack.com/tools/cloud-services-hub/azure-bastion)**: Azure CLI provisions Bastion hosts and uses their native-client support to open SSH or RDP connections, or to establish a tunnel to a target VM without giving that VM a public IP address.
- **[Azure Cloud Shell](https://blowstack.com/tools/cloud-services-hub/azure-cloud-shell)**: Azure Cloud Shell runs a preinstalled Azure CLI in the browser. Azure CLI can use the shell’s authenticated session without requiring a local installation.
- **[Azure portal](https://blowstack.com/tools/cloud-services-hub/azure-portal)**: Azure CLI can run in the portal’s built-in Cloud Shell. The portal also offers Cloud Shell command-line entry points without requiring a local Azure CLI installation.

## Alternatives to Azure CLI in other clouds

### AWS

**[AWS Command Line Interface (AWS CLI)](https://blowstack.com/tools/cloud-services-hub/aws-command-line-interface-(aws-cli))**: AWS CLI and Azure CLI are free, cross-platform tools for managing cloud resources from a terminal or script. AWS CLI targets AWS accounts and Regions and supports IAM roles and identity federation, while Azure CLI targets Azure subscriptions and supports managed identities and federated service principals for automation.

| | Azure CLI | AWS Command Line Interface (AWS CLI) |
| --- | --- | --- |
| Resource targeting | Azure subscription | AWS account and Region |
| Automation identities | Managed identity or federated principal | IAM roles or identity federation |

Compared Nov 2026.

## What is Azure CLI

Azure CLI runs on Windows, macOS, and Linux and is available in Azure Cloud Shell and as a container image. Cloud Shell is useful for browser-based administration without a local installation. For continuous integration and delivery, pin the CLI version or container image so that jobs do not pick up new command behavior unexpectedly. Run az version to see the installed CLI and extension versions, and append --help to a command to check its available arguments and examples.

For interactive administration, sign in with az login and confirm the tenant and subscription with az account show before making changes. In automation, pass the target subscription ID explicitly where supported instead of relying on the runner's default. Use a managed identity on a supported Azure host or a federated service principal in a compatible pipeline rather than scripting a user sign-in. Grant permissions at the narrowest scope that supports the task. A role that can manage a storage account, for example, does not necessarily grant permission to read its blobs.

Choose an output format based on how the result will be used. Table output is convenient for terminal inspection, while JSON preserves nested properties for downstream processing. Use --query with a JMESPath expression to select a single property, such as a resource ID, and --output tsv to capture that value without JSON quoting. Test scripts in the shell that will run them because Bash and PowerShell handle quoting and variable expansion differently. Do not write access tokens, connection strings, or secret values to shared logs.

For repeatable infrastructure changes, keep the desired configuration in version-controlled Bicep files or Azure Resource Manager templates and use the CLI to submit deployments. At resource-group scope, run az deployment group what-if to review predicted changes before running az deployment group create. Use direct service commands for targeted tasks, such as checking a resource's provisioning state or updating a specific setting. If a command returns early because it was run with --no-wait, use the corresponding wait command where available or check the operation's status before starting dependent work.

Some command groups are distributed as extensions. Install the required extensions explicitly on build runners, record their versions alongside the base CLI version, and test upgrades before rolling them out. Review release notes for changes to command defaults, and set explicit values when a default would change the infrastructure a script creates.
