When I am trying to create Search Service using ARM Template, it showing the below error
The relative path ‘artifacts/linkedTemplate.json’ could not be
resolved. Please ensure the parent deployment references either an
external URI or a template spec ID. The relativePath property cannot
be used when creating a template deployment with a local file.
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"searchService_name": {
"type": "string"
}
},
"variables": {
"linked-template": "artifacts/azure_deploycopy.json"
},
"resources": [
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2021-04-01",
"name": "azure-restore",
"properties": {
"mode": "Incremental",
"templateLink": {
"relativePath": "[variables('linked-template')]"
},
"parameters": {
"searchService_name": {
"value": "[parameters('searchService_name')]"
}
}
}
}
],
"outputs": {}
}
2
Answers
Could you please add more details about deployment?
@NithinViswanathan Based on your comment I figured why it doesn’t work for you and how to move forward. As in another answer – Azure Resource Manager (ARM) doesn’t know about your local dependency. For such complex deployments to work you need to create Template Spec first.
Template spec will contain your main template and will include dependant folders and/or templates.
For this to work start with creating template spec:
this will create resource such as this:
Template spec image
find template spec ID and deploy it:
When using nested/linked templates in Azure you need to use a URI that azure can access when deploying your template. This means that it shouldn’t be local unless deploying through the azure cloud shell.
MS Learn has a lot of good information about arm templates and linked templates.