I've create an Azure VM in RM and have deleted the VM and Components expect the OSDisk in an Premium Storage Account (Blobs). Now i wouldd like to create an new VM and attach the OS Disk to the new VM.

I've tried to use the Set-AzureRmVmOsDisk, to an existing VM. That does not work. I also tried creating a new VM and modify the OSDisk. But there is the Error:

New-AzureRmVM : Changing property 'osDisk.name' is not allowed.

Any idea on how to create an new VM and assign an OS .vhd from an old VM as new System Disk`?

EDIT: I've tried the following:

$VM = Get-AzureRmVM -Name "VM01" -ResourceGroupName "TestResource1"
Set-AzureRmVMOSDisk -VM $VM -Name "**VM123456**.vhd" -VhdUri "https://vm01disk.blob.core.windows
.net/vhds/**VM123456**.vhd" -CreateOption Attach

The output show:

 "osDisk": {
   "osType": null,
   "encryptionSettings": null,
   "name": "VM123456.vhd",
   "vhd": {
     "uri": "https://vm01disk.blob.core.windows.net/vhds/**VM123456**.vhd"

After running the command:

Get-AzureRmVM -Name "VM01" -ResourceGroupName "TestResource1"

again, i can see:

"osDisk": {
  "osType": "Windows",
  "encryptionSettings": null,
  "name": "VM01",
  "vhd": {
    "uri": "https://vm01disk.blob.core.windows.net/vhds/**VMoldID**.vhd"

There was no Error, and the prompt from the command indicates the changes have been done. But when calling the infos from the VM again, there is still the old vhd

  • What message do you get when you attempt the Set-AzureRmVmOsDisk?
    – MikeWo
    Mar 25 '16 at 14:37
  • I do the Follwing, please see EDIT above.
    – Berndinox
    Mar 25 '16 at 14:47

To create a new VM, using the existing disk you should be able to do so with the following PowerShell (this is simplified, I haven't added any NICS etc.).

$vm = New-AzureRMVMConfig -VMName $vmName -VMSize $vmSize
$osDiskUri = "https://nameofyourstorageaccount.blob.core.windows.net/vhds/nameofyourvhd.vhd"
$vm = Set-AzureRMVMOSDisk -VM $vm -Name $osDiskName -VhdUri $osDiskUri -CreateOption attach -Windows
New-AzureRMVM -ResourceGroupName $rgName -Location $location -VM $vm 

In case if you need non-power-shell way out of this then following worked for me.

I had accidentally deleted one of the SQL Server VM from my SharePoint 2013 farm using the new Azure Portal. The disk VHD file was still intact on the blob storage of my storage account as usual.

  1. Download CloudXplorer. Launch > Manage Account> Azure Blob Storage Account. Enter storage account name and the key (you'll get it from azure portal). You see all VHD files, etc. Locate the one that matches name of the VM you deleted. Pick the most recent one that you want to restore to. Note down its full name (*.vhd). Then, right click on that and select break lease.

  2. Go back to Azure Portal. Delete the NIC and disassociate the Public Static IP. Create a new VM with exactly same configuration as before. When it is ready, it will provision new NIC and new OS Disk. Stop the VM and go to Disks section in the properties. Note down the full url of the VHD file in use. Go back to CloudXplorer and hit refresh. Search for the new VHD that was created and copy its name. Delete it. Then rename the original one with the name you copied.

  3. Go back to Azure Portal. Associate the public static IP with newly created NIC for the new VM. (In my case internal IP's were preserved because no other VMs were being provisioned at that moment.) Then, start the VM. That's it.

No impact on the SharePoint farm.

  • Using cloud explorer to break the lease is new magic for me. I've always built templates which attach an exiting disk. The above is faster, more flexible, and less work. Genius! Why MSFT doesn't allow this in the portal is BEYOND comprehension. Mar 9 '17 at 2:44
  • I actually didn't need to do anything with the nics for this to work. Nice call. Sep 6 '17 at 18:41

It is simple if you use Azure portal (New one). go to disks and make image from it. And then create new VM from that snap image.

  • 1
    He is trying to create a resource manager (v2) VM, you cannot do this from the old portal.
    – Sam Cogan
    Mar 28 '16 at 13:24
  • Thanks for your answer, in the new portal i can just see my storage account, and inside the blobs, there are my .vhds. I just have the option to download them. Can you provide me with a link to "Disks" inside the Manager?
    – Berndinox
    Mar 29 '16 at 6:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.