1
votes

Unable to use variables or parameters in ARM template where subscription id is required.

"subnetRef": "[concat('/subscriptions/',parameters('subscriptionid'),'/resourceGroups/',parameters('vnetrg'),'/providers/Microsoft.Network/virtualNetworks/',parameters('vnet'),'/subnets/',parameters('subnet'))]",

Result:

\"LinkedInvalidPropertyId\",\r\n \"message\": \"Property id '[variables('subnetRef')' at path 'properties.ipConfigurations[0].properties.subnet.id' is invalid. Expect fully qualified resource Id that start with '/subscriptions/{subscriptionId}' or '/providers/{resourceProviderNamespace}/'.\"\r\n }\r\n}"

1

1 Answers

2
votes

Here is an example of how I've set up the subnetRef resourceID path. Use the resourceId(...) function to build up the path, picking up the subscription ID part for you.

"vnetID": "[resourceId(variables('networkResourceGroupName'), 'Microsoft.Network/virtualNetworks',variables('virtualNetworkName'))]",
"subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetNameBack00'))]",

Reference: https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-template-functions-resource#resourceid