If you want to create a Vm with your own vhd file, you can create an Azure managed image with the VHD file then create VM with the image. For more details, please refer to here and here
For example
- Create Azure managed image
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"images_testimage_name": {
"defaultValue": "testimage1",
"type": "String"
},
"blobUri": {
"defaultValue": "<your vhd file url>",
"type": "String"
},
"location": {
"defaultValue": "",
"type": "String"
}
},
"variables": {},
"resources": [
{
"type": "Microsoft.Compute/images",
"apiVersion": "2019-07-01",
"name": "[parameters('images_testimage_name')]",
"location": "[parameters('location')]",
"properties": {
"storageProfile": {
"osDisk": {
"osType": "Linux",
"osState": "Generalized",
"diskSizeGB": 30,
"blobUri": "[parameters('blobUri')]",
"caching": "ReadWrite",
"storageAccountType": "Premium_LRS"
},
"dataDisks": [],
"zoneResilient": true
},
"hyperVGeneration": "V1"
}
}
]
}
- Create VM
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
},
"variables": {},
"resources": [
... other resource
{
"name": "[parameters('virtualMachineName')]",
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "2020-06-01",
"location": "[parameters('location')]",
"properties": {
"hardwareProfile": {
"vmSize": "[parameters('virtualMachineSize')]"
},
"storageProfile": {
"osDisk": {
"createOption": "fromImage",
"managedDisk": {
"storageAccountType": "Premium_LRS"
}
},
"imageReference": {
"id": "<the resource id of the image you create in step1>"
}
},
... other configurations
}
}
]
}