How to define storageaccounttype as standard HDD_LRS in New-azVM create commandline

Rahul Singh Chandel 0 Reputation points
2023-05-15T08:29:55.6866667+00:00
ew-AzVM `
  -ResourceGroupName "RG1" `
  -Name "VM1" `
  -Location "eastus" `
  -ImageName "Win2019Datacenter" `
  -Size "Standard_DS2_v2" `
  -Credential (Get-Credential -UserName "rahul" -Message "#Passion008") `
  -OsDiskName "myVM_OSDisk" `
  -OsType "Windows"
  -StorageAccountType "StandardHDD_LRS" `
  -Verbose

Azure Disk Storage
Azure Disk Storage
A high-performance, durable block storage designed to be used with Azure Virtual Machines and Azure VMware Solution.
585 questions
{count} votes

1 answer

Sort by: Most helpful
  1. AirGordon 7,030 Reputation points
    2023-05-15T08:46:13.3266667+00:00

    Standard_LRS

    The PowerShell cmdlet that you are looking for is Set-AzVMOSDFisk
    The 4 options for StorageAccountType are; Premium_LRS, Standard_LRS , StandardSSD_LRS and UltraSSD_LRS

    $vm = Set-AzVMOSDisk -VM $vm -ManagedDiskId $osDisk.Id -StorageAccountType Standard_LRS -DiskSizeInGB 128 -CreateOption Attach -Windows
    

    You'd use it in VM Creation like this;

    $vmName = "myVM" $vmConfig = New-AzVMConfig -VMName $vmName -VMSize "Standard_A2"
    $vm = Add-AzVMNetworkInterface -VM $vmConfig -Id $nic.Id
    $vm = Set-AzVMOSDisk -VM $vm -ManagedDiskId $osDisk.Id -StorageAccountType Standard_LRS -DiskSizeInGB 128 -CreateOption Attach -Windows
    New-AzVM -ResourceGroupName $destinationResourceGroup -Location $location -VM $vm
    

    For more information, see https://learn.microsoft.com/en-us/azure/virtual-machines/attach-os-disk?tabs=powershell and https://learn.microsoft.com/en-us/powershell/module/az.compute/set-azvmosdisk?view=azps-9.7.1