8

Is there a way to take a backup of a VM (image capture following the sysprep method) and then make that image in the gallery visible to someone under their subscription. For example, I create a VM, archive it off to the image gallery, then my colleague comes along and wants to create a VM from that image (the colleague cannot be a co-administrator on my subscription).

Alternatively, is there just a way to move the VM to a different subscription without archving it off and recreating?

Have found the following but this is a bit convoluted and requires purchase of third party software

http://gauravmantri.com/2012/07/04/how-to-move-windows-azure-virtual-machines-from-one-subscription-to-another/

Many thanks

Richard Clarke

2 Answers2

6

I don't think you can use images created in one subscription to create VMs in another subscription. You would need to copy those images into your subscription. Since images are nothing but Page Blobs in your storage account, you would need to copy them into a storage account in your target subscription, create images off of them and then deploy VMs. I'm not aware of any other way around it.

Regarding your comment about requires purchase of third party software, that's not really true. You don't have to buy 3rd party software. The main thing is to move your VHDs (which are page blobs) from one subscription to another. Do take a look at Step 1 - Copy Blobs in that blog post. It has a link to console application with source code that you can use to copy blob across. I used Cloud Storage Studio to explore my blob storage. You can use any other storage explorer to check the contents of blob storage (including Windows Azure portal). Cerebrata recently released a free blob storage explorer which you may want to check out: http://www.cerebrata.com/labs/azure-explorer.

Unfortunately that's the only way that I know of to create Azure VMs from images created under different subscriptions.

Gaurav Mantri
  • 128,066
  • 12
  • 206
  • 241
  • Hi Gaurav Thanks for the reply - I've downlaoded the azure-explorer - this gives me the kind of UI I need. Is there a way to avoid copying the vhd via my local internet connection - it seems to be pulling it down to then copy it up. I'm completely new to Azure so don't really understand the console application / source code part you reference in your reply. – Richard Clarke - SSP May 16 '13 at 13:26
  • The copy blob operation is a server side asynchronous operation. So ideally the tool (Azure Explorer) should not be downloading the VHD and then uploading it. If it is doing it, then there's something wrong. So the console application essentially initiates the copy blob operation and constantly monitors it's progress. As an alternative, you can also use Az-Copy: http://blogs.msdn.com/b/windowsazurestorage/archive/2013/04/01/azcopy-using-cross-account-copy-blob.aspx. HTH. – Gaurav Mantri May 16 '13 at 13:40
  • Installed Azure Explorer on the Azure VM itself, can now copy the vhd blobs directly between storage accounts in the Azure cloud itself. Many thanks for your help - just need to create the new VM from the disk following your instructions. – Richard Clarke - SSP May 16 '13 at 14:21
1

This is now possible using Azure Shared Image Galleries

Edit:

@Shanky the subscription ID is part of the resource ID for the image version. It will look like this:

/subscriptions/$subscriptionId/resourceGroups/$resourceGroup/providers/Microsoft.Compute/galleries/$galleryName/images/$galleryImageDefinition/versions/$imageVersion

You pass that as the ImageReference.id when creating a VM. It's similar to creating a VM from a marketplace image but you just pass the ImageReference ID instead of the publisher/sku/etc.

Aaron
  • 161
  • 2
  • 10
  • Could you talk about how exactly can we do this? I want to achieve this via the java SDK. While creating a VM out of an image I don't see any option to select the subscription. – Vivek Shankar Jul 14 '20 at 06:33
  • Thanks I figured it out after I posted that comment. I just wanted to point out that if you're doing these operations via an app registration, to create the VM in another subscription your service principal should have access to the other subscription. If required, you'll need to grant READER RBAC access. – Vivek Shankar Aug 06 '20 at 03:06