0

'Unable to evaluate template language function 'resourceId': all function arguments must be string literals.'

I have written an ARM template to deploy a Load Balancer and attach a Backend Pool to that. When I deploy, I get the above error.

I am unable to distinguish any of the resourceID references as anything other than strings. Hopefully somebody else notices what I've missed.

Resource code below:

Thank you!


``{ //APP ILB Create
"type": "Microsoft.Network/loadBalancers",
"apiVersion": "2022-09-01",
"name": "\[concat(parameters('CompName'),'-APP-ILB')\]",
"location": "\[parameters('region')\]",
"sku": {
"name": "Standard",
"tier": "Regional"
},
"properties": {
"frontendIPConfigurations": \[
{
"name": "LoadBalancerFrontEnd",
"id": "\[concat(resourceId('Microsoft.Network/loadBalancers', variables('APPILBName'), '/frontendIPConfigurations/LoadBalancerFrontEnd'))\]",
"properties": {
"privateIPAddress": "\[concat('192.',parameters('VNET_IP'),'.0.101')\]",
"privateIPAllocationMethod": "Static",
"subnet": {
"id": "\[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('vnetName'))\]"
},
"privateIPAddressVersion": "IPv4"
},
"zones": \[
"3",
"2",
"1"
\]
}
\],
"backendAddressPools": \[
{
"name": "\[variables('APPPOOLName')\]",
"id": "\[resourceId('Microsoft.Network/loadBalancers/backendAddressPools', variables('APPILBName'), variables('APPPOOLName'))\]",
"properties": {
"loadBalancerBackendAddresses": \[
{
"name": "7f4ac3aa-9d43-4c8f-9c8f-3a20cfb276a1",
"properties": {
"ipAddress": "\[concat('192.',parameters('VNET_IP'),'0.6')\]",
"virtualNetwork": {
"id": "\[resourceId('Microsoft.Network/virtualNetworks/', variables('vnetName'))\]"
}
}
},
{
"name": "918c1bbb-24bc-47ea-b7ad-bc3a80e877c4",
"properties": {
"ipAddress": "\[concat('192.',parameters('VNET_IP'),'0.7')\]",
"virtualNetwork": {
"id": "\[resourceId('Microsoft.Network/virtualNetworks/', variables('vnetName'))\]"
}
}
}
\]
}
}
\],
"loadBalancingRules": \[
{
"name": "DATA_RULE",
"id": "\[resourceId('Microsoft.Network/loadBalancers', variables('APPILBName'), '/loadBalancingRules/DATA_RULE')\]",
"properties": {
"frontendIPConfiguration": {
"id": "\[resourceId('Microsoft.Network/loadBalancers', variables('APPILBName'), '/frontendIPConfigurations/LoadBalancerFrontEnd')\]"
},
"frontendPort": 50025,
"backendPort": 50025,
"enableFloatingIP": false,
"idleTimeoutInMinutes": 4,
"protocol": "Tcp",
"enableTcpReset": false,
"loadDistribution": "Default",
"disableOutboundSnat": true,
"backendAddressPool": {
"id": "\[resourceId('Microsoft.Network/loadBalancers/backendAddressPools', concat(variables('APPILBName'), variables('APPPOOLName')))\]"
},
"probe": {
"id": "\[resourceId('Microsoft.Network/loadBalancers', variables('APPILBName'), '/probes/DATA_PROBE')\]"
}
}
}
\],
"probes": \[
{
"name": "DATA_PROBE",
"id": "\[resourceId('Microsoft.Network/loadBalancers', variables('APPILBName'), '/probes/DATA_PROBE')\]",
"properties": {
"protocol": "Tcp",
"port": 50025,
"intervalInSeconds": 5,
"numberOfProbes": 1,
"probeThreshold": 1
}
}
\],
"inboundNatRules": \[\],
"outboundRules": \[\],
"inboundNatPools": \[\]
}
}`

`

Already Tried: Removed all concatenations in ResourceID references - no change. Converted all concatenated text into variables, and replaced references - no change. Compared all resourceID references with Microsoft Documentation.

artless noise
  • 21,212
  • 6
  • 68
  • 105
  • What does `Apppoolname`, `AppILBname` variables have? Make sure that `variable(Apppoolname)` is returning string value. Can you confirm here. @dchambers6222 – Jahnavi Aug 29 '23 at 04:49
  • Here are the definitions for those two variables: "APPILBName": [ "[concat(parameters('CompName'),'-APP-ILB')]" ], "APPPOOLName": [ "[concat(parameters('CompName'), '_APP_POOL')]" ] And CompName is defined as a string. – dchambers6222 Sep 01 '23 at 13:22

1 Answers1

0

'Unable to evaluate template language function 'resourceId': all function arguments must be string literals.'

The above error means that the arguments in resourceID must be string literals.

Considering all resourceId functions in your code:

The frontendIPConfigurations block has a resourceId function as well as a concat function. Check the value of variables('APPILBName'), because if it is not a string, the issue may occur.

As previously stated, ensure that the variables passed to the resourceID function of loadBalancingRules and backendAddressPools doesn't have any conflict as above.

Instead of passing it as

"id": "\[concat(resourceId('Microsoft.Network/loadBalancers', variables('APPILBName'), '/frontendIPConfigurations/LoadBalancerFrontEnd'))\]",

Store the pool name or any user defined variable in a variable argument like APPILBName and pass it to the resourceID function.

"id": "[resourceId('Microsoft.Network/loadBalancers', variables('APPILBName'), variable('frontendIPConfigurations'))]",

Referring to the ARM template from MSDoc, I tried deploying a load balancer with the backend address pools and was successful as shown.

{
      "type": "Microsoft.Network/loadBalancers",
      "apiVersion": "2021-05-01",
      "name": "[variables('loadBalancer')]",
      "location": "[parameters('location')]",
      "sku": {
        "name": "Standard"
      },
      "properties": {
        "frontendIPConfigurations": [
          {
            "properties": {
              "subnet": {
                "id": "[variables('subnetRef')]"
              },
              "privateIPAddress": "10.0.2.6",
              "privateIPAllocationMethod": "Static"
            },
            "name": "LoadBalancerFrontend"
          }
        ],
        "backendAddressPools": [
          {
            "name": "BackendPool1"
          }
        ],
        "loadBalancingRules": [
          {
            "properties": {
              "frontendIPConfiguration": {
                "id": "[resourceId('Microsoft.Network/loadBalancers/frontendIpConfigurations', variables('loadBalancer'), 'LoadBalancerFrontend')]"
              },
              "backendAddressPool": {
                "id": "[resourceId('Microsoft.Network/loadBalancers/backendAddressPools', variables('loadBalancer'), 'BackendPool1')]"
              },
              "probe": {
                "id": "[resourceId('Microsoft.Network/loadBalancers/probes', variables('loadBalancerName'), 'lbprobe')]"
              },
              "protocol": "Tcp",
              "frontendPort": 80,
              "backendPort": 80,
              "idleTimeoutInMinutes": 20
            },
            "name": "lbrule"
          }
        ],
        "probes": [
          {
            "properties": {
              "protocol": "Tcp",
              "port": 80,
              "intervalInSeconds": 15,
              "numberOfProbes": 2
            },
            "name": "lbprobe"
          }
        ]
      }
}

enter image description here

enter image description here

Jahnavi
  • 3,076
  • 1
  • 3
  • 10