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
- Launch Cloud Shell from the top navigation of the Azure portal
- Select a subscription to create a storage account and Azure file share
- Select "Create storage"
You are automatically authenticated for Azure CLI 2.0 in every sesssion.
Select the Bash environment
- Select the environment drop down from the the left hand side of shell window
- Select Bash
Set your subscription
- List subscriptions you have access to:
az account list
- Set your preferred subscription:
az account set --subscription my-subscription-name
Your subscription will be remembered for future sessions using
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
/User/.ssh/id_rsa.pub by Azure CLI 2.0 by default. Your .ssh folder is persisted in your attached Azure file 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
- Search for your VM name in the Azure portal search bar
- Click "Connect" and run:
Upon establishing the SSH connection, you should see the Ubuntu welcome prompt.
Delete your resource group and any resources within it:
az group delete -n MyRG