How to create vm using custom image from different storage account, on Azure

前端 未结 5 1570
没有蜡笔的小新
没有蜡笔的小新 2021-01-14 11:39

I\'m currently using this template to create a vm by custom image. For the OS Disk part:

\"storageProfile\": {
  \"osDisk\": {
    \"name\": \"[concat(variab         


        
相关标签:
5条回答
  • 2021-01-14 11:59

    I don't know how other answers are upvoted. OP post is correct - custom image and VM os disk needs to be in the same storage account which is a great limitation. Just tried that using the API and I'm getting:

    "MsRestAzure::AzureOperationError: ConflictingUserInput: Source and destination storage accounts for disk test-terminate are different."
    
    0 讨论(0)
  • 2021-01-14 12:02

    It is a requirement that the source image and the destination vhd reside in the same storage account, however it is not required that the storage account be in the same resource group as the VM. It must be in the same region/location, but does not have to be in the same resource group.

    So you can set up a storage account beforehand, put your source image in there and not have to worry about copying it during deployment, that will happen automatically. Here's a snippet of how I configure my templates:

    "userImageName":"[concat('http://',parameters('userImageStorageAccountName'),'.blob.core.windows.net/',parameters('userImageStorageContainerName'),'/',parameters('userImageVhdName'))]",
    "osDiskVhdContainer": "[concat('http://',parameters('userImageStorageAccountName'),'.blob.core.windows.net/',parameters('vmImageStorageContainerName'),'/')]"
    

    Same storage account but different containers for images and vhds.

    So make sure:

    1. source and dest are in the same storageAccount
    2. VM and storage are in the same region (e.g. East Asia)
    3. use a new storage account (provisioned by ARM) not "classic"
    0 讨论(0)
  • 2021-01-14 12:05

    Here is what I found from launching VM from Azure ARM custom image through my test:

    1. The custom image can be in different storage account other than the VM
    2. The custom image storage account need to be within same subscription, same region and same resource group as the VM

    I tried launching VM from custom image from different resource group and storage account(same subscription, same region) and got error: "Source and destination storage accounts for disk are different" But if I launch VM from custom image from different storage account while resource group is the same, I get my VM launched without error.

    0 讨论(0)
  • 2021-01-14 12:13

    For me it has just worked like this:

    Prerequisite - The Storage Account with the User Image VHD should BE THE SAME, in the SAME GROUP.

    Then, it worked.

    0 讨论(0)
  • 2021-01-14 12:14

    If by different storage account you mean a storage account in another subscription, then no. The storage account and virtual machine must be in the same subscription.

    UPDATE

    Found the answer in the template description page here: https://github.com/Azure/azure-quickstart-templates/tree/master/101-vm-from-user-image

    Prerequisite - The Storage Account with the User Image VHD should already exist in the same resource group.

    So based on this, as long as your storage accounts are in same Azure Subscriptions and are in same Resource Group, you should be fine even if the storage accounts are different.

    0 讨论(0)
提交回复
热议问题