title: Linked ARM templates result in Invalid Template
body: <p>Let's start with what I'm trying to accomplish.</p>
  
  <p>What I'd like to do is create an ARM template where I'm retrieving secrets from the Azure Key Vault, without specifying too much details on the specific Key Vault. Sounds easy enough and probably something which is implemented in every production system.</p>
  
  <p>Doing a quick search I discovered <a href="https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-keyvault-parameter#reference-a-secret-with-dynamic-id" rel="nofollow noreferrer">the syntax for such a thing is the following</a>. </p>
  
  <pre><code>"parameters": {
    "adminPassword": {
      "reference": {
        "keyVault": {
          "id": "[resourceId(subscription().subscriptionId,  parameters('vaultResourceGroup'), 'Microsoft.KeyVault/vaults', parameters('vaultName'))]"
        },
        "secretName": "[parameters('secretName')]"
      }
    },
  </code></pre>
  
  <p>From what I gather you need to add this in an external template as the used methods can't be used in the 'main' method.</p>
  
  <p>So I started creating a 'main' ARM template and a new template called <code>appservice.json</code> which contains all of the stuff necessary for my App Service, including the <code>appSettings</code> block which need the secrets from Key Vault.</p>
  
  <p>In my main template I've done the following, <a href="https://github.com/MicrosoftDocs/azure-docs/blob/master/articles/azure-resource-manager/resource-group-linked-templates.md#using-variables-to-link-templates" rel="nofollow noreferrer">as described in the documentation</a>.</p>
  
  <pre><code>{
        "apiVersion": "2017-05-10",
        "name": "linkedTemplate",
        "type": "Microsoft.Resources/deployments",
        "properties": {
          "mode": "Incremental",
          "templateLink": {
            "uri": "[uri(deployment().properties.templateLink.uri, 'appservice.json')]",
            "contentVersion": "1.0.0.0"
          },
  </code></pre>
  
  <p>However, when deploying I'm confronted with the following error.</p>
  
  <pre><code>"error": {
      "code": "InvalidTemplate",
      "message": "Unable to process template language expressions for resource '/subscriptions/ba49bae7-2b37-4504-914b-441763a2bcd3/resourceGroups/cfpexchange-jan-test/providers/Microsoft.Resources/deployments/linkedTemplate' at line '1' and column '1526'. 'The language expression property 'templateLink' doesn't exist, available properties are 'name, properties'.'"
    }
  </code></pre>
  
  <p>I also tried the following because I noticed IntelliSense in Visual Studio told me <code>properties</code> doesn't exits and I should use <code>templateLink</code> directly.</p>
  
  <pre><code>{
        "apiVersion": "2017-05-10",
        "name": "linkedTemplate",
        "type": "Microsoft.Resources/deployments",
        "properties": {
          "mode": "Incremental",
          "templateLink": {
            "uri": "[uri(deployment().templateLink.uri, 'appservice.json')]",
            "contentVersion": "1.0.0.0"
          },
  </code></pre>
  
  <p>This of course isn't right either.</p>
  
  <pre><code>   "error": {
      "code": "InvalidTemplate",
      "message": "Unable to process template language expressions for resource '/subscriptions/ba49bae7-2b37-4504-914b-441763a2bcd3/resourceGroups/cfpexchange-jan-test/providers/Microsoft.Resources/deployments/linkedTemplate' at line '1' and column '1526'. 'The language expression property 'templateLink' doesn't exist, available properties are 'name, properties'.'"
    }
  </code></pre>
  
  <p>And when using it as a variable, like in the documentation</p>
  
  <pre><code>"variables": {
      "sharedTemplateUrl": "[uri(deployment().properties.templateLink.uri, 'shared-resources.json')]"
    },
  ...
  "properties": {
          "mode": "Incremental",
          "templateLink": {
            "uri": "[variables('sharedTemplateUrl')]",
            "contentVersion": "1.0.0.0"
          },
  </code></pre>
  
  <p>I'm also getting an error.</p>
  
  <blockquote>
    <p>2018-07-04T19:14:34.4204720Z ##[error]Deployment template validation failed: 'The template variable 'sharedTemplateUrl' is not valid: The language expression property 'templateLink' doesn't exist, available properties are 'template, parameters, mode, debugSetting, provisioningState'.. Please see <a href="https://aka.ms/arm-template-expressions" rel="nofollow noreferrer">https://aka.ms/arm-template-expressions</a> for usage details.'.</p>
  </blockquote>
  
  <p>At this time I'm a bit lost. From what I understand from the documentation it appears I'm doing everything correct. Apparently I'm not. Any ideas on how to continue with this?</p>
  
  <p>For completeness, the two actual files which I'm using at this time:</p>
  
  <ul>
  <li><p>The main ARM template: <a href="https://github.com/Jandev/CfpExchange/blob/b998bb0c49cf369b2f7584e20556aefb5224ace0/Deployment/CFPExchange.json" rel="nofollow noreferrer">https://github.com/Jandev/CfpExchange/blob/b998bb0c49cf369b2f7584e20556aefb5224ace0/Deployment/CFPExchange.json</a></p></li>
  <li><p>The linked template: <a href="https://github.com/Jandev/CfpExchange/blob/522f48aa19d19730e5474ce11ead57a48d330389/Deployment/appservice.json" rel="nofollow noreferrer">https://github.com/Jandev/CfpExchange/blob/522f48aa19d19730e5474ce11ead57a48d330389/Deployment/appservice.json</a></p></li>
  </ul>
  
  <p>There have been multiple iterations on it in order to try and fix it, but as mentioned noting appeared to be working so far.</p>