Unable to create image using Azure VM

2019-09-14 00:07发布

I need to generalize and capture a linux virtual machine.

I deployed the VM using ARM template. In ARM template, I used the following to get VHD stored in storage account

            "storageProfile": {
                "imageReference": {
                    "publisher": "[variables('imagePublisher')]",
                    "offer": "[variables('imageOffer')]",
                    "sku": "[variables('imageSku')]",
                    "version": "latest"
                },
                "osDisk": {
                    "name": "[parameters('virtualMachineName')]",
                    "createOption": "fromImage",
                    "vhd": {
                        "uri": "[concat(concat(reference(resourceId(variables('resourceGroupName'), 'Microsoft.Storage/storageAccounts', parameters('storageAccountName')), '2015-06-15').primaryEndpoints['blob'], 'vhds/'), parameters('virtualMachineName'), concat(uniqueString(resourceGroup().id), '.vhd'))]"
                    }
                },
                "dataDisks": []
            },

Now I am following this document to create and image and VM.

When I execute the following command, I am getting error

az image create --resource-group myResourceGroup --name myImage --source myVM

The storage account containing blob https://testvmstorage.blob.core.windows.net/vhds/testvmyrg5wfer6xbcg.vhd is or has been encrypted. Copy the blob to an unencrypted storage account before importing. 

1条回答
地球回转人心会变
2楼-- · 2019-09-14 00:30

When your storage account is encryption, you will get the error log. You could check it on Azure Portal. enter image description here

Now, if you want to the VHD to create a image, you need create a non-encryption account and copy the VHD to it. You could use Azcopy to copy VHDs between containers. Just an example below:

AzCopy /Source:https://shuidisks446.blob.core.windows.net/vhds /Dest:https://shuidiag102.blob.core.windows.net/vhds /SourceKey:sGqtdFHQWQWYyf2tRWGF5jkeAEubTp13AVaeTM25QogxXE+K0Ezq1ulcs18qGVPhCEp6ULdLLbKVa7fMbUvYZg== /DestKey:iCjeS+eegjkSJXHjH2UqCkqXnUPiCGvxaOG0Ad2LoPgUnvBoWl9wQJtC1jc//lOj4CF7khpLQe791P4QeyTY6Q== /Pattern:shui20161222141315.vhd

After the VHD transfers to new storage account, you could use the VHD to create a snapshot, then use the snapshot to create image.

Note: You could not create image with VHD directly.

You could use the following commands.

az snapshot create -g shui2 -n shuisna --source https://shui2.blob.core.windows.net/vhds/shui20170607110945.vhd
az image create -g shui2 -n shuiimage --source shuisna --os-type linux
查看更多
登录 后发表回答