Create an image from a .vhd disk on Microsoft Windows Azure – error VHD is already registered with image repository

This post discusses how to create an image from a VHD file of a VM you have on Windows Azure to re-use it with other VMs and also shows a resolution to the issue/error: “xxx.vhd is already registered with image repository as the resource with ID xxx” on Windows Azure management portal.

I have a nice windows azure virtual machine with its .vhd drive that I managed to get to an excellent state with all my software installed, configured and working smoothly. I wanted to make this VHD as an Image in my Windows Azure cloud account so that I can create multiple virtual machines (VM) based on the same VHD disk. Here is what I did:

First, I did a sysprep on this nice VM as follows: On the Virtual Machine, Open command prompt as an administrator and navigate to your C:\Windows\System32\Sysprep folder. Then run the Sysprep.exe file. Make sure the generalise option is ticked and select “quit” instead of “shut down” in the actions after sysprep (There is a known issue that happens sometimes when you select shutdown).

Once this is done, I have shut down my VM, went to my Windows Azure management / Control Panel ( and selected the VM and then deleted it. Make sure you select the option to delete VM and retain / keep the VHD hard disk files attached to this VM. This will only delete the Virtual Machine but will keep the VHD virtual disks for you.

Following that, if you go and try to create an image for ths VHD file, you will probably get the error: “xxx.vhd is already registered with image repository as the resource with ID xxx” from Windows Azure. This issue will mostly because the VHD file is still allocated to the disk that was created for the VM (which is now deleted). You will now need to go to Virtual Machines under your Windows Azure Control Panel, click on “disks” tab (you should have Virtual Machines, Images and Disks tabs there). Click on the disk that is allocated to the VHD file and delete it. Make sure you choose to keep and retain the VHD file. This VHD file is still kept in your storage section on Windows Azure.

Now that the disk and the VM are both deleted, you can go to Images tab under Virtual machines and select create image, point to the VHD file and create your image. Make sure you select the tick box: yes I have sysprep my VHD.

You now have an image that you can use to create as many Virtual machines as you want based on it. You just need to go to the Virtual Machines tab and click on create virtual machine and select your VHD from the Gallery.

There are other issues where the disk and the VM are deleted and you are still unable to use the VHD file. In this case, a Windows Azure explorer software may be needed to connect to your Windows Azure cloud account and release the VHD as it is probably still in lease (a lease on the blob) and there is no lease ID specified (because the VM and the disk are deleted). Here is an article explaining the resolution to this issue:


In addition to having the image out of the VHD on windows azure, you can also have a disk instead if you don’t have a sysprep VHD. In this case, you create a disk out of the VHD and then create a VM out of the Disk instead of out of the image. The main difference is that when you create a VM from an image, windows azure creates a copy of the VHD and associates the VM to it while if you creatte a VM from a Disk, it just uses the same VHD – which means you can only use this disk/VHD once with one VM. This is usually a good work around if you are getting the error: Virtual Machine running but provision timed out on your Virtual Machine: Running (Provision timeout).

Hope this helps!

How to setup & configure your Hyper-V guest virtual machines to connect to the Internet & to your host windows 8 Laptop or server 2012 to share folders (External & Internal virtual switches)

Building development and presentation or demo Virtual Machines on Windows 8 professional laptops or desktops and using Microsoft Hyper V is now fairly common. Hyper V server is now available to work on Windows 8 professional which was previously only possible on Windows Server 20012 (and 2008). We used to have to build our laptops on windows server 2012 operating system due to this limitation previously but now it is very common to have hyper-v running on Pre-Sales Consultants and Architects laptops (and even tablets such as Surface now).

A common challenge/issue with the setup of Hyper-V Virtual Machines is the internal and external networking of the virtual machine and how you can get your Virtual Machine to work internally within your LAN so that it can connect to your host machine (Laptop or Desktop PC) and so that it can also have external Internet Connectivity. This also applies to setting up your Hyper-V server using Windows Server 2012 so that its guest virtual machines and the host server are all connected to one network and all have external connection to the Internet.

This topic has probably covered by many before but I still found that some people are stills struggling with it, hence I decided to write this post. I’ll try to make the post clear and focused in the form of bullet points to be an easy guide for anyone trying to setup the network adaptors on their Virtual Machines.

First thing you need to know is that I strongly recommend that you have two network adaptors in your Virtual Machine (VM): Internal and External adaptors. Similarly, you need to have two virtual switches created in your Virtual Switch Manager in Hyper-V: Internal Switch and External Switch to be used by the two virtual adaptors in your Virtual Machine.

Internal Adaptor will allow for the Virtual Machine to be accessible from within your host machine so that you can Remote Desktop (RDP) to your Virtual Machine using this internal linkage between your host (laptop or PC) and the VM. You also need this internal connection for sharing folders between the host and the virtual machine and to map network drives between them.

The External Adapter is required to allow for your Virtual Machine to be able to connect to the Internet through the host machine physical network card (NIC) (via the external switch).

Each virtual Adapter on a virtual machine requires a virtual Switch to be created on Hyper-V server.

So, firstly, you need an Internal Virtual Switch to get your internal VM adapter to use the host physical NIC (Network Card). Screenshot of how your virtual switch (internal) can be configured is below:

Virtual Internal Switch
Virtual Internal Switch

For this Internal connection, I suggest that you specify a static IP address for your Virtual Machine’s internal virtual adapter and your host’s internal adapter. This is to ensure that any shares between host and VM and the RDP connection have constant connection based on this IP. The IP address I used was for example: and for host & VM respectively with the VM’s default gateway equals to the Host IP (

You will then need an external virtual switch. When you create a new external virtual switch, the switch takes over from your physical host machine network card (NIC) and your NIC becomes just bridged to this external switch. Similarly, your Virtual Machines Adaptor will just connect to this virtual switch (external) and will then have the VM connected to the Internet. The external switch can be setup to connect to Ethernet or Wifi. I have chosen to make it to work with Ethernet. You can have another one for Wireless connection if you prefer. Screen shot of external virtual switch configuration is below:

Virtual External Switch
Virtual External Switch

When creating the external virtual switch please make sure that the option to: “Allow operating system to share the external switch” is ticked to allow for the Operating system to get the physical NIC of the host to connect to the internet via the external virtual switch.

Let’s say you have an Internet Router at home and you have done the above setup for the external virtual switch and virtual adapter in the VM, you will find that your external switch will take an IP address from this Router, your host machine will have a different IP as if it is a different device and your Virtual Machine’s external adapter will have another IP from the router. So 3 different IPs. I suggest that you keep these IP’s dynamic especially if this setup is on a your laptop or demo machine. The reason is that you must be connecting to different Internet connections via different routers and switches which each will give you a different IP for your virtual external switch. In this case, if your IPs are static, then every time you connect to a new Internet router, you need to change the IPs of all 3. If they are dynamic, then you do not need to do anything.

This means that your VM can be accessible internally from the host machine using this IP and this internal network via the router. You might here say then we do not need an internal virtual switch as the external one is enough. This is only true as long as you got your virtual switch connected to the If you disconnect your external virtual switch from the router, then you will not be able to access your VM from the host as the VM will lose this IP address and if you decide to use static IP addresses for this external connection, you will find that every time you go from home to office, you need to change IP addresses of the external adapters.

Hence, and for all of the above reasons, I strongly suggest that you have an internal virtual switch for permanent connection between your host and virtual machine… and an external virtual switch for Internet connection for both your VM and your host machine (Laptop/PC/Server).


  • Please note that after creating the Virtual External Switch, the switch takes over the connection so you might need to restart your host machine.
  • Once restarted and as long as the option to allow operating system to share the external switch is ticked as mentioned before, then the host will get connected to the Internet as well.
  • If you started the Virtual Machine while the host is not connected to the Internet, you may need to renew the VM’s external adapter IP address. Either Disable & then Enable the VM’s external adapter if you want to renew the IP or simply run the renew IP command in a command prompt on the virtual machine. This is the case when you have a dynamic IP address on the VM’s external adapter.
  • Make sure you choose meaningful names for your virtual switches both external and internal and for your Virtual Machine virtual adapters.
  • Below is a screen shot of how my host machine (Windows 8 Laptop) has its network adapters named:
    Host Machine Network Adapters
    Host Machine Network Adapters

    Hyper-V names all virtual network adapters with vEthernet and then the name of the virtual switch between brackets. So you will find in the snapshot above that:
    vEthernet (Virtual External Switch) connects to my Hyper V Virtual External Switch and the other one for the Virtual Internal Switch.

  • Below is a screen shot of how the virtual machine network connection adapters look:

    Guest Virtual Machine Network Adapters
    Guest Virtual Machine Network Adapters
  • I also found the following post and video helpful: