The Azure command-line interface (CLI) is Microsoft's cross-platform command-line experience for managing Azure resources. The Azure CLI is designed to be easy to learn and get started with, but powerful enough to be a great tool for building custom automation to use Azure resources.

The Azure CLI is available to install in Windows, macOS and Linux environments. It can also be run in a Docker container and Azure Cloud Shell.

To install Azure CLI in PowerShell is super easy. Just execute:

Invoke-WebRequest -Uri -OutFile .\AzureCLI.msi; Start-Process msiexec.exe -Wait -ArgumentList '/I AzureCLI.msi /quiet'

And you can just use it directly.

But if you execute az in git-bash, it will tell you that az can not be found. It was because az is a file named az.cmd so bash doesn't treat as a command in bash.

So how can we use az and write az shell in bash?

After installing the Azure CLI, open a new bash instance with admin privilege.

And execute the following command:

echo \"C:\\Program Files \(x86\)\\Microsoft SDKs\\Azure\\CLI2\\wbin\\az.cmd\" \$1 \$2 \$3 \$4 \$5 \$6 \$7 \$8 \$9 \${10} \${11} \${12} \${13} \${14} \${15} > "$SYSTEMROOT\az"

That will create a new bash executable file named az under your system root.

Now try to execute az command in bash.