无法使用 Azure VM 创建映像

Unable to create image using Azure VM

我需要概括并捕获一个 linux 虚拟机。

我使用 ARM 模板部署了 VM。在 ARM 模板中,我使用以下方法将 VHD 存储在存储帐户

            "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": []
            },

现在我正在按照这个 document 来创建和映像以及 VM。

当我执行以下命令时,出现错误

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. 

当您的存储帐户被加密时,您将收到错误日志。您可以在 Azure 门户上查看它。

现在,如果你想用VHD创建镜像,你需要创建一个非加密账户,然后将VHD复制到里面。您可以使用 Azcopy 在容器之间复制 VHD。下面只是一个例子:

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

VHD转移到新的存储帐户后,您可以使用VHD创建快照,然后使用快照创建镜像。

注意:不能直接用VHD创建镜像。

您可以使用以下命令。

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