Objectives
In this article, you will:
- 1: Start a Bash session in Azure Cloud Shell
- 2: Create a resource group and an Azure managed disk by using Azure CLI
- 3: Configure the managed disk by using Azure CLI
1: Start a Bash session in Azure Cloud Shell
we will open a Bash session in Cloud Shell.
From the portal, open the Azure Cloud Shell by clicking on the icon in the top right of the Azure Portal.
If prompted to select either Bash or PowerShell, select Bash.
If this is the first time you are starting Cloud Shell and you are presented with the You have no storage mounted message, select the subscription you are using in this lab, and click Create storage.
If prompted, click Create storage, and wait until the Azure Cloud Shell pane is displayed.
Ensure Bash appears in the drop-down menu in the upper-left corner of the Cloud Shell pane.
2: Create a resource group and an Azure managed disk by using Azure CLI
we will create a resource group and an Azure managed disk by using Azure CLI session within Cloud Shell.
To create a resource group in the same Azure region as the az104-03c-rg1 resource group you created in the previous lab, from the Bash session within Cloud Shell, run the following:
shLOCATION=$(az group show --name 'az104-03c-rg1' --query location --out tsv) RGNAME='az104-03d-rg1' az group create --name $RGNAME --location $LOCATION
To retrieve properties of the newly created resource group, run the following:
shaz group show --name $RGNAME
To create a new managed disk with the same characteristics as those you created in the previous labs of this module, from the Bash session within Cloud Shell, run the following:
shDISKNAME='az104-03d-disk1' az disk create \ --resource-group $RGNAME \ --name $DISKNAME \ --sku 'Standard_LRS' \ --size-gb 32
When using multi-line syntax, ensure that each line ends with back-slash (
\
) with no trailing spaces and that there are no leading spaces at the beginning of each line.To retrieve properties of the newly created disk, run the following:
shaz disk show --resource-group $RGNAME --name $DISKNAME
3: Configure the managed disk by using Azure CLI
we will managing configuration of the Azure managed disk by using Azure CLI session within Cloud Shell.
To increase the size of the Azure managed disk to 64 GB, from the Bash session within Cloud Shell, run the following:
shaz disk update --resource-group $RGNAME --name $DISKNAME --size-gb 64
To verify that the change took effect, run the following:
shaz disk show --resource-group $RGNAME --name $DISKNAME --query diskSizeGb
To change the disk performance SKU to Premium_LRS, from the Bash session within Cloud Shell, run the following:
shaz disk update --resource-group $RGNAME --name $DISKNAME --sku 'Premium_LRS'
To verify that the change took effect, run the following:
shaz disk show --resource-group $RGNAME --name $DISKNAME --query sku
Clean up resources
Remember to remove any newly created Azure resources that you no longer use. Removing unused resources ensures you will not see unexpected charges.
In the Azure portal, open the Bash shell session within the Cloud Shell pane.
List all resource groups created throughout the labs of this module by running the following command:
shaz group list --query "[?starts_with(name,'az104-03')].name" --output tsv
Delete all resource groups you created throughout the labs of this module by running the following command:
shaz group list --query "[?starts_with(name,'az104-03')].[name]" --output tsv | xargs -L1 bash -c 'az group delete --name $0 --no-wait --yes'
The command executes asynchronously (as determined by the --nowait parameter), so while you will be able to run another Azure CLI command immediately afterwards within the same Bash session, it will take a few minutes before the resource groups are actually removed.
Subscribe by Email
Follow Updates Articles from This Blog via Email
No Comments