I am trying to create a azure vm using powershell so that it would allow to attach unmanaged data disks in future. I see documentation on creating but those always create with managed disks
Asked
Active
Viewed 1,372 times
1 Answers
0
nic\network\etc amended
# Create storage account
$storageAccount = New-AzStorageAccount -ResourceGroupName "MyResourceGroup" -AccountName "MyStorageAccount" -Location $location -SkuName "Standard_LRS"
# Add disk
$OSDiskUri = $storageAccount.PrimaryEndpoints.Blob.ToString() + "vhds/vm-disk.vhd"
$vm = Set-AzVMOSDisk -VM $vm -Name "vm-disk" -VhdUri $OSDiskUri -CreateOption fromImage
# Create VM
New-AzVM -ResourceGroupName myResourceGroup -Location $location -VM $vm

4c74356b41
- 69,186
- 6
- 100
- 141
-
This creates VM's OS with the unmanaged disk. I am looking for attaching unmanaged data disk (Add-AzVMDataDisk). – hemanth s Jun 13 '19 at 20:06
-
same way, create them and attach: https://learn.microsoft.com/en-us/powershell/module/azurerm.compute/add-azurermvmdatadisk?view=azurermps-6.13.0#examples – 4c74356b41 Jun 13 '19 at 20:27
-
That doesn't work. Because with the above the vm is created by default to use managed data disks. So trying to add unmanaged data disk will error out – hemanth s Jun 13 '19 at 20:44
-
no, with the above the vm would be created with a regular disk – 4c74356b41 Jun 13 '19 at 20:47
-
Correct. I want to create a VM with standard linux OS disk such that it should support adding unmanaged data disk later – hemanth s Jun 13 '19 at 20:57