Wednesday, July 7, 2021

thumbnail

Managing Azure resources by Using Azure PowerShell

Objectives

In this article, you will:

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

1: Start a PowerShell session in Azure Cloud Shell

we 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.

    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.

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

we 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:

    powershell
    $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:

    powershell
    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:

    powershell
    $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:

    powershell
    Get-AzDisk -ResourceGroupName $rgName -Name $diskName

3: Configure the managed disk by using Azure PowerShell

 we will managing 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:

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

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

    powershell
    (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:

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

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


Subscribe by Email

Follow Updates Articles from This Blog via Email

No Comments

Powered by Blogger.