skip to Main Content

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


  1. Could you please add more details about deployment?

    • Do you deploy with PS, AZCLI, do you set working folder?
    • Where is linked template located – locally or as template spec
    • Folder structure with linked templates

    @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:

    az ts create --name <name_of _tempsepc> -g <destination_resourcegroup> -f <main template path ie. ./maintemplate.json>  -v <template version ie. 1.0.0> --version-description "init template specs" -l <location ie. westeurope>
    

    this will create resource such as this:

    Template spec image

    find template spec ID and deploy it:

    id = $(az ts show --name <template_spec_name> --resource-group <template spec rg> --version "1.0.0.0" --query "id")
    
    az deployment group create 
      --resource-group <target rg> 
      --template-spec $id
    
    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search