0

hoping someone can help pinpoint what's missing in my approach.

I'm using visual studio 2017 if this makes any difference.

I've two arm templates; maintemplate and the linkedtemplate.

In the maintemplate I'm trying to reference a linked template and retrieve an output value from it in my maintemplate's outputs section so that the outputs contains values from both the templates.

Here is the linkedtempalte outputs section;

"outputs": {
    "LoadBalancer-pip1": {
      "type": "string",
      "value": "[reference(resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName1'))).IpAddress]"
    },
    "LoadBalancer-pip1-DNS-Name": {
      "type": "string",
      "value": "[reference(resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName1'))).dnsSettings.fqdn]"
    }
  }

Here is the maintemplate outputs section;

"outputs": {
    "jump Box VM Public IP address": {
      "type": "string",
      "value": "[reference(resourceId('Microsoft.Network/publicIPAddresses',variables('hub-cc-jbox-pipName'))).IpAddress]"
    },
    "Load Balancer VIP1": {
      "type": "string",
      "value": "[reference('hub-plb').outputs.LoadBalancer-pip1.value]"
    },
    "Load Balancer VIP1 DNS Name": {
      "type": "string",
      "value": "[reference('hub-plb').outputs.LoadBalancer-pip1-DNS-Name.value]"
    }
}

Accordingly to this link; https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-linked-templates#link-or-nest-a-template

it should be possible as long as it's not a nested template, which it's not.

Here is my maintemplate section where I'm making the link to the linkedtempalte;

{
        "name": "hub-plb",
        "type": "Microsoft.Resources/deployments",
        "apiVersion": "2017-05-10",
        "dependsOn": [],
        "properties": {
          "mode": "Incremental",
          "templateLink": {
            "uri": "[concat(parameters('_artifactsLocation'), '/', variables('hub-plbTemplateFolder'), '/', variables('hub-plbTemplateFileName'), parameters('_artifactsLocationSasToken'))]",
            "contentVersion": "1.0.0.0"
          },
          "parametersLink": {
            "uri": "[concat(parameters('_artifactsLocation'), '/', variables('hub-plbTemplateFolder'), '/', variables('hub-plbTemplateParametersFileName'), parameters('_artifactsLocationSasToken'))]",
            "contentVersion": "1.0.0.0"
          }
        }
      }

When I try to validate / deploy the template it fails with this message;

VERBOSE: Performing the operation "Creating Deployment" on target "xyz-rg".
08:23:09 - New-AzureRmResourceGroupDeployment : 8:23:08 AM - Error: Code=InvalidTemplate; Message=Deployment template validation 
08:23:09 - failed: 'The template output 'Load Balancer VIP1' at line '1034' and column '31' is not valid: The language expression 
08:23:09 - 'reference('hub-plb').outputs.LoadBalancer-pip1.value' is not valid: the string character 'p' at position '42' is not 
08:23:09 - expected..

Any help much appreciated.

  • 1
    can you try this: "[reference('hub-plb').outputs['LoadBalancer-pip1-DNS-Name']value]" or try changing output name so it doesnt have a - in it. I'd also suggest renaming every output to a string without - or ` ` – 4c74356b41 Nov 26 '18 at 14:28
  • any luck yet? can you give feedback? – 4c74356b41 Nov 27 '18 at 4:48
  • @4c74356b41 thanks for the hint. The validation passed after I removed the "-" from the output names. The syntax I had is right so all I did to make the validation passed is to change the name and removed any "-" or space from it. e.g. "LoadBalancerVIP1": { "type": "string", "value": "[reference('hub-plb').outputs.LoadBalancerpip1.value]" }, – csaif7 Nov 28 '18 at 0:37
  • I also posted a note on the MSFT article link for them to consider adding a note to avoid this validation failure. – csaif7 Nov 28 '18 at 0:54
  • ok, consider accepting this answer :) – 4c74356b41 Nov 28 '18 at 5:40
0

In this case the problem was with the output name, after removing the - from it, everything started to work.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.