Follow

Prepare Azure VM Image

Here are the steps to capture an image of a VM in the Resource Manager model in Azure:

1.  Log into the server you have built and configured with the Endur/Findur MSIs etc.  See here for details.

2.  Run sysprep (if you want a sysprepped image)

  • Cd  %windir%\system32\sysprep
  • Sysprep.exe

3.  Log into Azure using Azure Powershell with

  • Login-AzureRmAccount
  • Note: This needs to be be Azure Powershell v1.0 or above

4.  The status of the server should be 'stopped' in the Azure portal - check this.

5.  Deallocate the VM using powershell

  • Stop-AzureRmVM -ResourceGroupName <Resource Group Name that the VM is in> -Name <Server Name>
  • (Note the resource group name is the same as the one created when we created the server)

6.  Check that the server is in a deallocated state

7.  Set the status of the VM to Generalized - needed as Azure cannot understand the sysprep fully

  1. Set-AzureRmVm -ResourceGroupName <Resource Group Name> -Name <Server Name> -Generalized

8.  Create new Storage Account and Container if needed. For example

9.  Create a new Container within the storage account:

10.  Capture the image to a destination storage container (e.g. in a folder called 'serverimages')

  • Command Format: 

Save-AzureRmVMImage -ResourceGroupName YourResourceGroup -VMName YourWindowsVM -DestinationContainerName <e.g. serverimages> -VHDNamePrefix YourTemplatePrefix -Path Yourlocalfilepath\Filename.json

  • Storage Container URL:

This will match the path to the storage container set above.  For example:

https://cwjserverimages001.blob.core.windows.net/cwjserverimagescontainer001

  • Powershell command to run:

Save-AzureRmVMImage -ResourceGroupName <ResourceGroupName> -VMName <Server Name> -DestinationContainerName <StorageContainerName - e.g. serverimages> -VHDNamePrefix <Date>_IMAGE_<serverName> -path C:\Azure\<Date>_<ServerName>.json

11.  To see what has been created you need to download the Azure Storage Explorer tool from http://storageexplorer.com

  • The images are found under the storage account of the original server
  • You can also look at the URL / URI information from the JSON file that we specified as the output path in the above command
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

0 Comments

Article is closed for comments.
Powered by Zendesk