For system, network and cloud administrators

How to update Azure disk performance SKU using Azure PowerShell

After an initial deployment, you might run into the need of changing the initial disk performance SKU in Azure. In the example below, we’re updating the SKU from Standard_LRS to Premium_LRS. In your PowerShell session type:

New-AzDiskUpdateConfig -Sku Premium_LRS | Update-AzDisk -ResourceGroupName yourresourcegroup -Name yourdiskname


How to update the size of an Azure managed disk using Azure PowerShell

It comes helpful to know how to update the size of a newly created disk in Azure. So, in your PowerShell session type:

New-AzDiskUpdateConfig -DiskSizeGB 64 | Update-AzDisk -ResourceGroupName yourresourcegroup -DiskName thenameofyourdisk

Verify:

Get-AzDisk -ResourceGroupName yourresourcegroup -Name thenameofyourdisk

How to create an Azure resource group in the same region as previous resource group using Azure PowerShell

Sometimes it helps to create a resource group in Azure that has the same location as a specific desired resource group. Open an Azure PowerShell session and type:

$location = (Get-AzResourceGroup -Name theresourcegroupiwanttocopyfrom).Location
$rgname = 'thenewresourcegroup'
New-AzResourceGroup -Name $rgname -Location $location


How to verify if the Az PowerShell module is installed and imported

Az stands for the formal Azure PowerShell module containing cmdlets for Azure features. The following PowerShell code will search for the Az module and if it will not find it installed, it will with all of its dependencies. And then, it ill import it into the session.

if (-not (Get-Module Az -ListAvailable)) {
 Install-Module Az -Scope CurrentUser -Force -Verbose
 Import-Module -Name Az -Verbose
}
else { 
 Import-Module -Name Az -Verbose
}