Lab 03c - Manage Azure resources by Using Azure PowerShell

Student lab manual

Lab scenario

Now that you explored the basic Azure administration capabilities associated with provisioning resources and organizing them based on resource groups by using the Azure portal and Azure Resource Manager templates, you need to carry out the equivalent task by using Azure PowerShell. To avoid installing Azure PowerShell modules, you will leverage PowerShell environment available in Azure Cloud Shell.

Objectives

In this lab, you will:

  • Task 1: Start a PowerShell session in Azure Cloud Shell
  • Task 2: Create a resource group and an Azure managed disk by using Azure PowerShell
  • Task 3: Configure the managed disk by using Azure PowerShell

Estimated timing: 20 minutes

Architecture diagram

image

Instructions

Note: Always create your own secure password for any virtual machine or user account you create. If the virtual machine is created for you, use Reset password in the Portal to update the password.

Exercise 1

Task 1: Start a PowerShell session in Azure Cloud Shell

In this task, you will open a PowerShell session in Cloud Shell.

  1. In the portal, open the Azure Cloud Shell by clicking on the icon in the top right of the Azure Portal.

  2. If prompted to select either Bash or PowerShell, select PowerShell.

    Note: 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.

  3. If prompted, click Create storage, and wait until the Azure Cloud Shell pane is displayed.

  4. Ensure PowerShell appears in the drop-down menu in the upper-left corner of the Cloud Shell pane.

Task 2: Create a resource group and an Azure managed disk by using Azure PowerShell

In this task, you will create a resource group and an Azure managed disk by using Azure PowerShell session within Cloud Shell

  1. To create a resource group in the same Azure region as the az104-03b-rg1 resource group you created in the previous lab, from the PowerShell session within Cloud Shell, run the following:

    $location = (Get-AzResourceGroup -Name az104-03b-rg1).Location
    
    $rgName = 'az104-03c-rg1'
    
    New-AzResourceGroup -Name $rgName -Location $location
    
  2. To retrieve properties of the newly created resource group, run the following:

    Get-AzResourceGroup -Name $rgName
    
  3. To create a new managed disk with the same characteristics as those you created in the previous labs of this module, run the following:

    $diskConfig = New-AzDiskConfig `
     -Location $location `
     -CreateOption Empty `
     -DiskSizeGB 32 `
     -Sku Standard_LRS
    
    $diskName = 'az104-03c-disk1'
    
    New-AzDisk `
     -ResourceGroupName $rgName `
     -DiskName $diskName `
     -Disk $diskConfig
    
  4. To retrieve properties of the newly created disk, run the following:

    Get-AzDisk -ResourceGroupName $rgName -Name $diskName
    

Task 3: Configure the managed disk by using Azure PowerShell

In this task, you will be managing the configuration of the Azure managed disk by using Azure PowerShell session within Cloud Shell.

  1. To increase the size of the Azure managed disk to 64 GB, from the PowerShell session within Cloud Shell, run the following:

    New-AzDiskUpdateConfig -DiskSizeGB 64 | Update-AzDisk -ResourceGroupName $rgName -DiskName $diskName
    
  2. To verify that the change took effect, run the following:

    Get-AzDisk -ResourceGroupName $rgName -Name $diskName
    
  3. To verify the current SKU as Standard_LRS, run the following:

    (Get-AzDisk -ResourceGroupName $rgName -Name $diskName).Sku
    
  4. To change the disk performance SKU to Premium_LRS, from the PowerShell session within Cloud Shell, run the following:

    New-AzDiskUpdateConfig -Sku Premium_LRS | Update-AzDisk -ResourceGroupName $rgName -DiskName $diskName
    
  5. To verify that the change took effect, run the following:

    (Get-AzDisk -ResourceGroupName $rgName -Name $diskName).Sku
    

Clean up resources

Note: Do not delete resources you deployed in this lab. You will reference them in the next lab of this module.

Review Questions

  • Why do you need a storage account for a Cloud Shell?

Review

In this lab, you have:

  • Started a PowerShell session in Azure Cloud Shell
  • Created a resource group and an Azure managed disk by using Azure PowerShell
  • Configured the managed disk by using Azure PowerShell