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 (http://manage.windowsazure.com) 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:

http://social.msdn.microsoft.com/Forums/windowsazure/en-US/7381ea0e-0443-4b33-aa12-ba39df003409/error-deleting-vhd-there-is-currently-a-lease-on-the-blob-and-no-lease-id-was-specified-in-the?forum=WAVirtualMachinesforWindows

Update:

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!

SQL Server Reporting Services Error cannot decrypt the symmetric encryption key & website declined to show this web page

One of our “big and important” clients has approached us with an issue with their system. The problem is that reports are not accessible from the .NET application and CRM that we have built for them. If you try to open reports from these, you get the error in Internet Explorer saying “Website declined to show this webpage. The website requires you to login”. We were getting this error with everything related to reporting services. So when logged on the reports server machine, those urls:  http://localhost/reports , http://localhost/reportserver , http://localhost/reportsmanager all come back with this error or with the error 403 forbidden “Error 403 Forbidden access”.

To rectify this issue, I went through all the usual possible routes such as authentication on IIS, reports server and reports website on IIS. Made sure that all the application and system users have the right access to the reports server. Checked the application pool for the reports server, all these looked find with nothing that has been unchanged. I have also tried to check the reports server configuration manager. Went through all the usual steps to check that it is running and configured properly and again these were all fine with the nice green tick next to each step of the reports server configuration manager. I have also checked services running on the server and the server even viewer. All windows services and SQL reporting server services were running correctly and can be restarted with no issue.

 Then, a colleague of mine, tried to open reports from the management studio, and that was it. The error we got in the management studio was much more descriptive and helpful. The SSRS reports server management studio error said:

The report server cannot decrypt the symmetric key used to access sensitive or encrypted data in a report server database. You must either restore a backup key or delete all encrypted content. Report server disabled”

The problem here is because that the Reporting Services encryption key has been invalidated, in other words corrupted. This encryption key is stopping reporting services from returning any reports or even displaying the reports manager, etc..

To fix this issue, and after some research, there were two solutions to solve this issue (again solutions found by my colleague, not me!):

Solution1: In SSRS 2005, there is the encryption section on the left hand side.  We need to go to this section and restore the encryption key using a backup encryption key. The encryption key should probably (and hopefully) have been backed up during the setup of the Reporting Services. This encryption key should be regularly backed up and stored in a safe location along with the encryption key password. If you got this backup encryption key, and to solve this error, we need to restore it from the Reporting Services Configuration Manager, encryption section.

If you you don’t have backup of it, then you will have to go for the other longer and more annoying option which is:

Solution2You have to delete the encrypted content. This will remove the connection strings from all the reporting services data sources. Hence, in this case and after removing the encryption and generating a new one, you need to reset the data sources in Report Manager. Datasources could be shared (linked) or could be a separate data source for each report. You will need and update all these data sources after you removed the encryption.

 

Luckily! Our good client had the backup of the encryption key, so we only needed to do solution one (Thank God for that!). Well, to be fair, they searched on the server and found a file with extension ” *.snk “ on their server and it was the encryption key backup.

All SSRS encryption keys have file extension .snk.

That’s it.. problem solved. Thanks again to my colleagues work on these solutions.

 

MS CRM Key Generator error – Invalid Action – Microsoft CRM 4 Error.

I have just started my Microsoft CRM 4.0 VM, tried to run a .NET console application and I got a full list of errors although the code was working fine the night before! When I tried to open Microsoft CRM 4.0, I got an error “Invalid Action” with the sentence starting with “error in command”. This failure was happening with all CRM organisations not just related to a specific one.

When I checked my event log, I found the following errror:

Event Type: Error
Event Source: MSCRMKeyGenerator
Description:
Current active key (KeyType : CrmWRPCTokenKey) is expired. This can indicate that a key is not being regenerated properly. Current Active Key : CrmKey(…, ScaleGroupId:00000000-0000-0000-0000-000000000000, KeyType:CrmWRPCTokenKey, Expired:True, ValidOn: …, ExpiresOn: …, CreatedOn: …, etc..

When I searched for a cause/solution for this issues, I found this excellent post on Nishant Rana’s blog (http://nishantrana.wordpress.com/2008/06/11/invalid-action-error-microsoft-dynamics-crm-40/).

Following the advice on this page, I searched and started the Microsoft CRM Asynchronous Processing Service on the CRM server and this has solved the problem instantly for me.

Hope this helps!