'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.
The above error means that the arguments in
resourceIDmust be string literals.Considering all
resourceIdfunctions in your code:The
frontendIPConfigurationsblock has aresourceIdfunction as well as aconcatfunction. Check the value ofvariables('APPILBName'), because if it is not a string, the issue may occur.As previously stated, ensure that the variables passed to the
resourceIDfunction ofloadBalancingRulesandbackendAddressPoolsdoesn't have any conflict as above.Instead of passing it as
Store the pool name or any user defined variable in a variable argument like
APPILBNameand pass it to theresourceIDfunction.Referring to the ARM template from MSDoc, I tried deploying a load balancer with the backend address pools and was successful as shown.