The question in the title: "how to create VM with Json arm template using define VHD (or disk,snapshot) in azure?" Thanks for your help!
Asked
Active
Viewed 1,587 times
1
-
https://learn.microsoft.com/en-us/azure/virtual-machines/windows/ps-template – 4c74356b41 Nov 20 '18 at 15:24
-
Have you tried Googling that? – CSharpRocks Nov 20 '18 at 16:14
-
yes,but i cant find the answer( give me link please if its not hard for you – LolAsLol Nov 20 '18 at 16:41
-
I do not really understand what you mean with "using define template"? It will be helpful If you can provide more details. – Charles Xu Nov 21 '18 at 07:22
-
Im sorry. This is right question – LolAsLol Nov 21 '18 at 13:58
-
If you want to create the vm from a specific VHD file, you can take a look at [this](https://github.com/Azure/azure-quickstart-templates/blob/master/201-vm-specialized-vhd-new-or-existing-vnet/azuredeploy.json). – Charles Xu Nov 22 '18 at 01:46
-
THANK YOU SO MUCH! – LolAsLol Nov 22 '18 at 14:35
-
I would add the answer for others who look for this as you. You can accept it. – Charles Xu Nov 23 '18 at 06:28
1 Answers
1
You can create the vm from VHD file through the template. The steps are that you can upload the VHD file to an Azure storage account and create a managed disk from the VHD file. Then attach it to the VM.
Create the managed disk from the VHD file:
{
"type": "Microsoft.Compute/disks",
"apiVersion": "2018-04-01",
"name": "[variables('diskName')]",
"location": "[parameters('location')]",
"properties": {
"creationData": {
"createOption": "Import",
"sourceUri": "[parameters('osDiskVhdUri')]"
},
"osType": "[parameters('osType')]"
}
}
Attach the managed disk to the VM:
"storageProfile": {
"osDisk": {
"osType": "[parameters('osType')]",
"createOption": "Attach",
"managedDisk": {
"id": "[resourceId('Microsoft.Compute/disks', variables('diskName'))]"
}
}
}
You can get the whole template here.

Charles Xu
- 29,862
- 2
- 22
- 39