Azure CLI in Git Bash Azure CLI in Git Bash bash bash

Azure CLI in Git Bash


Sometimes commands in windows git bash need .cmd appended. Also, another way of installing the Azure-Cli is through Chocolatey https://chocolatey.org/

Try this command after Azure-Cli is installed:

az.cmd --version

Echoing mscrivo you can run the line below in CMD not PowerShell (elevated/admin)

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} > "C:\Program Files\Git\mingw64\bin\az" 

Now you should be able to run in Git bash:

az --version


artberri noted the best solution in a comment:

Add the following to your %USERPROFILE%\.bashrc or %USERPROFILE%\.profile

alias az='az.cmd'

However, if you want to be able to use az in bash scripts, you'll need something a little more drastic, run the following from cmd prompt:

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 essentially create a passthrough az command in your windows folder that can be run from anywhere and passes parameters through to az.cmd.


In case using Git bash, navigate to the following directory:

C:\Program Files\Git\etc\profile.d

Windows Explorer of Git bash Directory

Edit aliases.sh, then add a new alias for az as below:

alias az='az.cmd'

example of aliases.sh