Convert Figma logo to code with AI

Azure logoazure-cli

Azure Command-Line Interface

3,956
2,935
3,956
3,707

Top Related Projects

15,322

Universal Command Line Interface for Amazon Web Services

42,146

Terraform enables you to safely and predictably create, change, and improve infrastructure. It is a source-available tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.

62,307

Ansible is a radically simple IT automation platform that makes your applications and systems easier to deploy and maintain. Automate everything from code deployment to network configuration to cloud management, in a language that approaches plain English, using SSH, with no agents to install on remote systems. https://docs.ansible.com.

2,816

Issue tracker and mirror of kubectl code

Quick Overview

Azure CLI is Microsoft's command-line interface for managing Azure resources. It provides a set of commands for creating, managing, and monitoring Azure services directly from the command line or through scripts, offering a powerful alternative to the Azure portal for automation and management tasks.

Pros

  • Cross-platform compatibility (Windows, macOS, Linux)
  • Extensive coverage of Azure services and features
  • Supports automation through scripting
  • Regularly updated with new Azure features

Cons

  • Steep learning curve for newcomers to CLI tools
  • Can be slower for some tasks compared to GUI alternatives
  • Requires separate installation and updates
  • Some complex scenarios may still require portal or ARM templates

Code Examples

  1. Creating a resource group:
az group create --name MyResourceGroup --location eastus
  1. Deploying a web app:
az webapp create --resource-group MyResourceGroup --plan MyAppServicePlan --name MyWebApp
  1. Listing all virtual machines:
az vm list --output table
  1. Creating a storage account:
az storage account create --name mystorageaccount --resource-group MyResourceGroup --location eastus --sku Standard_LRS

Getting Started

  1. Install Azure CLI:

    • Windows: Download and run the installer from Microsoft's website
    • macOS: brew update && brew install azure-cli
    • Linux: Follow distribution-specific instructions from Microsoft's documentation
  2. Log in to your Azure account:

az login
  1. Set your subscription:
az account set --subscription "My Subscription Name"
  1. You're now ready to use Azure CLI commands to manage your Azure resources.

Competitor Comparisons

15,322

Universal Command Line Interface for Amazon Web Services

Pros of aws-cli

  • More comprehensive documentation and examples in the repository
  • Larger community and more frequent updates
  • Better support for scripting and automation tasks

Cons of aws-cli

  • Steeper learning curve for beginners
  • Less intuitive command structure compared to azure-cli
  • Requires more setup and configuration for initial use

Code Comparison

aws-cli:

import boto3

s3 = boto3.resource('s3')
for bucket in s3.buckets.all():
    print(bucket.name)

azure-cli:

az storage account list --query "[].name" -o tsv

The aws-cli example uses the boto3 library to list S3 buckets, while the azure-cli example uses a single command to list storage accounts. This demonstrates the difference in approach between the two CLIs, with aws-cli often requiring more code but offering more flexibility, and azure-cli providing simpler, more concise commands for common tasks.

Both CLIs are powerful tools for managing their respective cloud platforms, but they cater to different user preferences and use cases. aws-cli is generally more suited for advanced users and complex automation scenarios, while azure-cli offers a more user-friendly experience for those new to cloud management.

42,146

Terraform enables you to safely and predictably create, change, and improve infrastructure. It is a source-available tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.

Pros of Terraform

  • Multi-cloud support, allowing infrastructure management across various providers
  • Declarative syntax for defining infrastructure as code
  • Extensive ecosystem with a wide range of providers and modules

Cons of Terraform

  • Steeper learning curve for users new to infrastructure as code
  • Limited native support for imperative operations or complex workflows
  • Potential for state management challenges in large-scale deployments

Code Comparison

Terraform:

resource "azurerm_resource_group" "example" {
  name     = "example-resources"
  location = "West Europe"
}

Azure CLI:

az group create --name example-resources --location westeurope

Both Terraform and Azure CLI are powerful tools for managing Azure resources, but they serve different purposes. Terraform is a multi-cloud infrastructure as code tool, while Azure CLI is specific to Azure and provides a command-line interface for managing resources.

Terraform's declarative approach allows for better version control and collaboration, making it easier to manage complex infrastructure setups. Azure CLI, on the other hand, offers a more straightforward and familiar command-line experience for Azure-specific tasks.

The choice between the two depends on factors such as the scale of your infrastructure, multi-cloud requirements, and team expertise. For Azure-only environments, Azure CLI may be sufficient, while Terraform shines in multi-cloud scenarios and larger-scale deployments.

62,307

Ansible is a radically simple IT automation platform that makes your applications and systems easier to deploy and maintain. Automate everything from code deployment to network configuration to cloud management, in a language that approaches plain English, using SSH, with no agents to install on remote systems. https://docs.ansible.com.

Pros of ansible

  • Broader multi-cloud and on-premises support, not limited to Azure
  • Agentless architecture, simplifying deployment and management
  • Extensive community-contributed modules for various tasks

Cons of ansible

  • Steeper learning curve, especially for those new to infrastructure-as-code
  • Slower execution compared to native CLI tools like azure-cli
  • Requires more setup and configuration for Azure-specific tasks

Code comparison

ansible playbook example:

- name: Create Azure VM
  azure_rm_virtualmachine:
    resource_group: myResourceGroup
    name: myVM
    vm_size: Standard_DS1_v2
    admin_username: azureuser
    ssh_public_keys:
      - path: /home/azureuser/.ssh/authorized_keys
        key_data: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC..."

azure-cli command example:

az vm create \
  --resource-group myResourceGroup \
  --name myVM \
  --image UbuntuLTS \
  --admin-username azureuser \
  --ssh-key-value ~/.ssh/id_rsa.pub

Both examples create a virtual machine in Azure, but ansible uses a declarative YAML format, while azure-cli uses a more straightforward command-line approach. ansible offers more flexibility and can be integrated into larger automation workflows, while azure-cli provides a simpler, Azure-specific solution for quick tasks and scripting.

2,816

Issue tracker and mirror of kubectl code

Pros of kubectl

  • More focused and specialized for Kubernetes management
  • Lightweight and portable across different cloud providers
  • Extensive plugin ecosystem for extended functionality

Cons of kubectl

  • Limited to Kubernetes-specific operations
  • Requires additional tools for broader cloud management tasks
  • Steeper learning curve for users not familiar with Kubernetes concepts

Code Comparison

kubectl:

kubectl get pods
kubectl apply -f deployment.yaml
kubectl describe service my-service

azure-cli:

az aks get-credentials --resource-group myResourceGroup --name myAKSCluster
az aks nodepool list --resource-group myResourceGroup --cluster-name myAKSCluster
az aks scale --resource-group myResourceGroup --name myAKSCluster --node-count 3

Summary

kubectl is a specialized tool for managing Kubernetes clusters, offering focused functionality and portability. It's ideal for users working primarily with Kubernetes across different environments. However, it has limitations when it comes to broader cloud management tasks.

azure-cli provides a more comprehensive set of tools for managing Azure resources, including Kubernetes clusters (AKS). It offers a wider range of functionality but is specific to the Azure ecosystem.

The choice between these tools depends on the user's specific needs, whether they're focused solely on Kubernetes management or require broader Azure resource management capabilities.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Microsoft Azure CLI

Python Build Status Slack

A great cloud needs great tools; we're excited to introduce Azure CLI, our next generation multi-platform command line experience for Azure.

Take a test run now from Azure Cloud Shell!

Installation

Please refer to the install guide for detailed install instructions.

A list of common install issues and their resolutions are available at install troubleshooting.

Developer installation (see below)

Usage

$ az [ group ] [ subgroup ] [ command ] {parameters}

Get Started

Please refer to the "get started" guide for in-depth instructions.

For usage and help content, pass in the -h parameter, for example:

$ az storage -h
$ az vm create -h

Highlights

Here are a few features and concepts that can help you get the most out of the Azure CLI.

Azure CLI Highlight Reel

The following examples are showing using the --output table format, you can change your default using the az configure command.

Tab completion

We support tab-completion for groups, commands, and some parameters

# looking up resource group and name
$ az vm show -g [tab][tab]
AccountingGroup   RGOne  WebPropertiesRG

$ az vm show -g WebPropertiesRG -n [tab][tab]
StoreVM  Bizlogic

$ az vm show -g WebPropertiesRG -n Bizlogic

Query

You can use the --query parameter and the JMESPath query syntax to customize your output.

$ az vm list --query "[?provisioningState=='Succeeded'].{ name: name, os: storageProfile.osDisk.osType }"
Name                    Os
----------------------  -------
storevm                 Linux
bizlogic                Linux
demo32111vm             Windows
dcos-master-39DB807E-0  Linux

Exit codes

For scripting purposes, we output certain exit codes for differing scenarios.

Exit CodeScenario
0Command ran successfully.
1Generic error; server returned bad status code, CLI validation failed, etc.
2Parser error; check input to command line.
3Missing ARM resource; used for existence check from show commands.

Common scenarios and use Azure CLI effectively

Please check Tips for using Azure CLI effectively. It describes some common scenarios:

More samples and snippets

For more usage examples, take a look at our GitHub samples repo or https://docs.microsoft.com/cli/azure/overview.

Write and run commands in Visual Studio Code

With the Azure CLI Tools Visual Studio Code extension, you can create .azcli files and use these features:

  • IntelliSense for commands and their arguments.
  • Snippets for commands, inserting required arguments automatically.
  • Run the current command in the integrated terminal.
  • Run the current command and show its output in a side-by-side editor.
  • Show documentation on mouse hover.
  • Display current subscription and defaults in status bar.
  • To enable IntelliSense for other file types like .ps1 or .sh, see microsoft/vscode-azurecli#48.

Azure CLI Tools in Action

Data Collection

The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry as described in the repository. There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsoft's privacy statement. Our privacy statement is located at https://go.microsoft.com/fwlink/?LinkID=824704. You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices.

Telemetry Configuration

Telemetry collection is on by default. To opt out, please run az config set core.collect_telemetry=no to turn it off.

Reporting issues and feedback

If you encounter any bugs with the tool please file an issue in the Issues section of our GitHub repo.

To provide feedback from the command line, try the az feedback command.

[Microsoft internal] You may contact the developer team via azpycli@microsoft.com.

Developer installation

Docker

We maintain a Docker image preconfigured with the Azure CLI. See our Docker tags for available versions.

$ docker run -u $(id -u):$(id -g) -v ${HOME}:/home/az -e HOME=/home/az --rm -it mcr.microsoft.com/azure-cli:<version>

Edge builds

If you want to get the latest build from the dev branch, you can use our "edge" builds.

You can download the latest builds by following the links below:

PackageLink
MSIhttps://aka.ms/InstallAzureCliWindowsEdge
Homebrew Formulahttps://aka.ms/InstallAzureCliHomebrewEdge
Ubuntu Bionic Debhttps://aka.ms/InstallAzureCliBionicEdge
Ubuntu Focal Debhttps://aka.ms/InstallAzureCliFocalEdge
Ubuntu Jammy Debhttps://aka.ms/InstallAzureCliJammyEdge
RPM el8https://aka.ms/InstallAzureCliRpmEl8Edge

On Windows, you need to uninstall the official version before installing the edge build. (See https://github.com/Azure/azure-cli/issues/25607#issuecomment-1452855212)

You can easily install the latest Homebrew edge build with the following command:

# You need to uninstall the stable version with `brew uninstall azure-cli` first
curl --location --silent --output azure-cli.rb https://aka.ms/InstallAzureCliHomebrewEdge
brew install --build-from-source azure-cli.rb

You can install the edge build on Ubuntu Jammy with the following command:

curl --location --silent --output azure-cli_jammy.deb https://aka.ms/InstallAzureCliJammyEdge && dpkg -i azure-cli_jammy.deb

And install the edge build with rpm package on RHEL 8 or CentOS Stream 8:

dnf install -y $(curl --location --silent --output /dev/null --write-out %{url_effective} https://aka.ms/InstallAzureCliRpmEl8Edge)

Here's an example of installing edge builds with pip3 in a virtual environment. The --upgrade-strategy=eager option will install the edge builds of dependencies as well.

$ python3 -m venv env
$ . env/bin/activate
$ pip3 install --pre azure-cli --extra-index-url https://azurecliprod.blob.core.windows.net/edge --upgrade-strategy=eager

To upgrade your current edge build pass the --upgrade option. The --no-cache-dir option is also recommended since the feed is frequently updated.

$ pip3 install --upgrade --pre azure-cli --extra-index-url https://azurecliprod.blob.core.windows.net/edge --no-cache-dir --upgrade-strategy=eager

The edge build is generated for each PR merged to the dev branch as a part of the Azure DevOps Pipelines.

Get builds of arbitrary commit or PR

If you would like to get builds of arbitrary commit or PR, see:

Try new features before release

Developer setup

If you would like to setup a development environment and contribute to the CLI, see:

Configuring Your Machine

Authoring Command Modules

Code Generation

Contribute code

This project has adopted the Microsoft Open Source Code of Conduct.

For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

If you would like to become an active contributor to this project please follow the instructions provided in Microsoft Open Source Guidelines.