0

I want to be able to create a new Azure Virtual Machine using Powershell with a custom image. This custom image is in Azure Storage Account X and the new Virtual Machine will be created using Azure Storage Account Y. When I run these commands to create the new Virtual Machine:

Set-AzureSubscription -CurrentStorageAccount $StorageAccount -SubscriptionName $SubscriptionName

New-AzureVMConfig -Name $MachineName -InstanceSize $InstanceSize -ImageName $Image | 
    Add-AzureProvisioningConfig -Linux -LinuxUser $LinuxUser -Password $AdminPassword | 
    Set-AzureSubnet $subNet | 
    New-AzureVM -ServiceName $MachineName -VNetName $VNet -ErrorVariable errs

where $Image is the custom image in Storage Account X and CurrentStorageAccount set to Y for the Subscription, I get the following error:

The disk's VHD must be in the same account as the VHD of the source image 

If the custom image is in Storage Account Y the commands to create the new Virtual Machine work correctly.

Can an Azure Virtual Machine be created when the image is in a different Storage Account?

1 Answer 1

2

Apparently not. However, you could copy the image from storage account X to storage account Y before you create the new VM. It would only add a few more lines to your script.

Here is an example:

http://michaelwasham.com/windows-azure-powershell-reference-guide/copying-vhds-blobs-between-storage-accounts/

Sign up to request clarification or add additional context in comments.

1 Comment

I was hoping that wasn't the case.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.