DeploymentFailed: InvalidTemplate: The language expression property ‘outputs’ doesn’t exist

If you’re getting the following error:

{
  "code": "DeploymentFailed",
  "message": "At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.",
  "details": [
    {
      "code": "InvalidTemplate",
      "message": "Unable to process template language expressions for resource '/subscriptions/545818ad-ab01-2022-a359-18bc24b4b4d3/resourceGroups/LogicAppPoc1/providers/Microsoft.Resources/deployments/Linked-1' at line '22' and column '9'. 'The language expression property 'outputs' doesn't exist, available properties are 'templateHash, parameters, mode, provisioningState, timestamp, duration, correlationId, providers, dependencies, outputResources'.'"
    }
  ]
}

Or a similar one:

{
  "code":"DeploymentFailed",
  "message":"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.",
  "details":[
    {
      "code":"InvalidTemplate",
      "message":"Unable to process template language expressions for resource '/subscriptions/545818ad-ab01-2022-a359-18bc24b4b4d3/resourceGroups/LogicAppPoc1/providers/Microsoft.Resources/deployments/Linked-1' at line '22' and column '9'. 'The language expression property 'templateLink' doesn't exist, available properties are 'template, templateHash, parameters, mode, debugSetting, provisioningState, validationLevel'.'"
    }
  ]
}

Then likely you’re trying to read the outputs of a nested template by a reference but it fails:

{
  "parameters": {
    "foo": {
      "value": "[reference('Linked-1').outputs.foo.value]"
    }
}

My particular case was little more complex: I’m trying to reference multiple nested deployments in a loop and produce an array from their respective outputs:

{
  "outputs": {
    "foos": {
        "type": "array",
        "copy": {
          "count": "[length(parameters('foos'))]",
          "input": "[reference(format('Linked-{0}', copyIndex()).outputs.foo.value]"
      }
  }
}

The only solution I’ve managed to get working was to replace a nested template with a linked:

{
  "parameters": {
    "template_Foos": {
      "type": "string"
    }
  },
  "resources": [
    {
      "name": "Foos",
      "type": "Microsoft.Resources/deployments",
      "apiVersion": "2021-04-01",
      "properties": {
        "mode": "Incremental",
        "templateLink": {
          "uri": "[parameters('template_Foos')]",
          "contentVersion": "1.0.0.0"
        }
      }
    }
  ],
  "outputs": {
    "foos": {
      "type": "array",
      "value": "[reference('Foos').outputs.foos.value]"
    }
  }
}

And then:

{
  "$schema": "https://schema.management.azure.com/schemas/2019-08-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "foos": {
      "type": "array"
    }
  },
  "resources": [],
  "outputs": {
    "foos": {
      "type": "array",
      "copy": {
        "count": "[length(parameters('foos'))]",
        "input": "[parameters('foos')[copyIndex()]]"
      }
    }
  }
}

That’s it, folks!

This entry was posted in Infrastructure and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.