I wanted to deploy a vm with managed disks . I have already created a managed disk in another resource group and I want to use this during the template deployment. I am currently blocked here.
I am Using the below parameter here existingVirtualNetworkResourceGroup , this has the managed disk I wanted to use it in my template.
parameters:
"existingVirtualNetworkResourceGroup": { "type": "string", "defaultValue": "poc-rg", "allowedValues": [ "poc-rg" ],
varibales:
"managedDisklocation":"[resourceId(parameters('existingVirtualNetworkResourceGroup'), 'Microsoft.Compute/disks')]",
"managedDiskpath":"[concat(variables(managedDisklocation),'/poc-manageddisk')]"
resources:
{
"apiVersion": "2015-05-01-preview",
"type": "Microsoft.Compute/virtualMachines",
"name": "[variables('vmNameMdb')]",
"location": "[resourceGroup().location]",
"dependsOn": ["[concat('Microsoft.Storage/storageAccounts/', variables('newStorageAccountName'))]",
"[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]"],
"properties": {
"hardwareProfile": {
"vmSize": "[parameters('vmSize')]"
},
"osProfile": {
"computerName": "[variables('vmNameMdb')]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]",
"secrets": [{
"sourceVault": {
"id": "[parameters('keyVaultSubscriptionId')]"
},
"vaultCertificates": [{
"certificateUrl": "[parameters('engineCertificate')]"
}],
"vaultCertificates": [{
"certificateUrl": "[parameters('vmAgentCertificate')]"
}]
}]
},
"storageProfile": {
"imageReference": {
"publisher": "[parameters('imagePublisher')]",
"offer": "[parameters('imageOffer')]",
"sku": "[parameters('imageSKU')]",
"version": "latest"
},
"osDisk": {
"createOption": "FromImage"
},
"dataDisks": [
{
"lun": 0,
"name": "[concat(parameters('vmName'),'-datadisk1')]",
"createOption": "attach",
"managedDisk": {
"id": "[parameters(managedDiskpath)]"
}
}
]
},
"networkProfile": {
"networkInterfaces": [{
"id": "[resourceId('Microsoft.Network/networkInterfaces',variables('nicName'))]"
}]
}
}
},
Error:
Deployment template validation failed: 'The template variable 'managedDisklocation' is not valid: Unable to evaluate template language function 'resourceId': the type 'Microsoft.Compute/disks' requires '1' resource name argument(s). Please see https://aka.ms/arm-template-expressions/#resourceid for usage details.. Please see https://aka.ms/arm-template-expressions for usage details.'. (Code: InvalidTemplate)