Sunday, April 16, 2017

Azure CLI 2.0 on Windows Bash shell

I recently wrote how to install Azure CLI 2.0 on Windows 10:

Configuring Azure CLI 2.0 on Windows 10

However, another option now with Windows 10 is to use the Bash Shell. Here’s the process of how to install both Bash and Azure CLI 2.0 on Windows 10

image

You’ll firstly need to install the Bash shell on Windows 10. To do this navigate to Settings in Windows 10. Then select For developers as shown above. Now select Developer mode.

image

You’ll be prompted to turn on developer mode. Select Yes to continue.

image

Windows will firstly search for the appropriate package

image

and then install it.

image

When complete you should receive a message, as shown above, that indicates you may need to restart your PC. You don’t have to reset just yet.

image

Go to Control Panel and select the option to Turn Windows features on or off. From the list that appears, locate and select Windows Subsystem for Linux (Beta) as shown above and then select OK.

image

Once the changes have been made you will need to reboot your PC.

image

Once rebooted select the Windows Start Menu and type bash. Select the bash option from the menu that appears.

image

Hit Y to continue.

image

The bash shell will be downloaded from the Windows Store as shown above.

image

It will then be installed.

image

When that is complete, you’ll need to enter a bash shell admin user name and password. This doesn’t have to be the same as you PC login but make sure you remember the details.

image

The bash shell installation will complete as you can see above.

image

If you now return to Windows Start Menu and enter bash you will see the option has changed to Bash on Ubuntu on Windows.

image

Next step is to ensure the Ubuntu subsystem is up to date. To do this enter the following command at the bash shell:

sudo apt-get update

image

Next, enter the command:

sudo apt-get upgrade

Once that is complete enter the following command:

echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ wheezy main" | \ sudo tee /etc/apt/sources.list.d/azure-cli.list

image

Then:

sudo apt-key adv --keyserver packages.microsoft.com --recv-keys 417A0893

image

Then:

sudo apt-get install apt-transport-https

image

Finally:

sudo apt-get update && sudo apt-get install azure-cli

to actually install Azure CLI 2.0.

image

image

Now if you type:

az

at the command prompt you should see the Azure CLI appear as shown above.

Remember, Azure CLI is designed to be a cross platform tool. That means it works on both Windows 10 and Bash on Windows 10 as well as Mac, Linux, etc. This makes it a great way to manage Azure from any platform.