Quickstart for Bash in Azure Cloud Shell

This document details how to use Bash in Azure Cloud Shell in the Azure portal.


A PowerShell in Azure Cloud Shell Quickstart is also available.

Start Cloud Shell

  1. Launch Cloud Shell from the top navigation of the Azure portal
  2. Select a subscription to create a storage account and Microsoft Azure Files share
  3. Select "Create storage"


You are automatically authenticated for Azure CLI 2.0 in every sesssion.

Select the Bash environment

  1. Select the environment drop down from the the left hand side of shell window
  2. Select Bash

Set your subscription

  1. List subscriptions you have access to:
    az account list
  2. Set your preferred subscription:
    az account set --subscription my-subscription-name


Your subscription will be remembered for future sessions using /home/<user>/.azure/azureProfile.json.

Create a resource group

Create a new resource group in WestUS named "MyRG":
az group create -l westus -n MyRG

Create a Linux VM

Create an Ubuntu VM in your new resource group. The Azure CLI 2.0 will create SSH keys and setup the VM with them.
az vm create -n my_vm_name -g MyRG --image UbuntuLTS --generate-ssh-keys


The public and private keys used to authenticate your VM are placed in /home/<user>/.ssh/id_rsa and /home/<user>/.ssh/id_rsa.pub by Azure CLI 2.0 by default. Your .ssh folder is persisted in your attached Azure Files share's 5-GB image.

Your username on this VM will be your username used in Cloud Shell ($User@Azure:).

SSH into your Linux VM

  1. Search for your VM name in the Azure portal search bar
  2. Click "Connect" and run: ssh username@ipaddress

Upon establishing the SSH connection, you should see the Ubuntu welcome prompt.

Cleaning up

Delete your resource group and any resources within it:
Run az group delete -n MyRG

Next steps

Learn about persisting files for Bash in Cloud Shell
Learn about Azure CLI 2.0
Learn about Azure Files storage