Articles → MICROSOFT AZURE → Create The Data Disk In Azure Using PowerShell
Create The Data Disk In Azure Using PowerShell
PowerShell Command
$resourcegroup = 'RG'
$machinename = 'myVM'
$location = 'North Europe'
$storageType = 'Standard_LRS'
$dataDiskName = 'newdisk01'
$dataDiskSize = 20
$datadiskConfig = New-AzDiskConfig -SkuName $storageType -Location $location -CreateOption Empty -DiskSizeGB $dataDiskSize
$dataDisk01 = New-AzDisk -DiskName $dataDiskName -Disk $datadiskConfig -ResourceGroupName $resourcegroup
$vm = Get-AzVM -Name $machinename -ResourceGroupName $resourcegroup
$vm = Add-AzVMDataDisk -VM $vm -Name $dataDiskName -CreateOption Attach -ManagedDiskId $dataDisk01.Id -Lun 1
Update-AzVM -VM $vm -ResourceGroupName $resourcegroup
Click to Enlarge
Output
Click to Enlarge