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.
When your storage account is encryption, you will get the error log. You could check it on Azure Portal.
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:
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.