Search code examples
azureazure-resource-managerazure-rm-template

Use [deployment().properties.templateLink.uri] on local deployments through ARM templates


When I try to use an ARM linked Template like...

    {
      "type": "Microsoft.Resources/deployments",
      "apiVersion": "2018-05-01",
      "name": "[concat('EventHubLinkedTemplate-', parameters('eventHubNames')[copyindex('eventHubNameIterator')])]",
      "copy": {
        "name": "eventHubNameIterator",
        "count": "[length(parameters('eventHubNames'))]"
      },
      "properties": {
        "mode": "Incremental",
        "templateLink": {
          "uri": "[uri(deployment().properties.templateLink.uri, '/eventHub/template.json')]",
          "contentVersion": "1.0.0.0"
        },
        "parameters": {
          "consumerGroups": "[parameters('consumerGroups')]",
          "eventHubName": "[concat(variables('eventHubNamespace'), '/', parameters('eventHubNames'))]"
        }
      }
    }

... from parent ARM template, using deploy option of Visual Studio 2019 ARM project, the deployment fails within the next message:

07:48:12 - Resource Microsoft.Resources/deployments 'EventHubLinkedTemplate-test' failed with message '{
  "error": {
  "code": "InvalidTemplate",
  "message": "Unable to process template language expressions for resource '/subscriptions/********-****-****-****-************/resourceGroups/*****/providers/Microsoft.Resources/deployments/EventHubLinkedTemplate-test' at line '127' and column '9'. 'The language expression property 'templateLink' doesn't exist, available properties are 'template, templateHash, parameters, mode, provisioningState'.'",
    "additionalInfo": [
      {
        "type": "TemplateViolation",
        "info": {
          "lineNumber": 127,
          "positionNumber": 9,
          "snippet": ""
        }
      }
    ]
  }
}'

Does anyone knows any way to use [deployment().properties.templateLink.uri] on local deployments through ARM templates?

As far as I can found on the documentation, seems it is not supported yet...


Solution

  • No, it's impossible.

    As the official article said:

    The templateLink property is only returned when linking to a remote template with a URL. If you're using a local template, that property isn't available.