Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

copyIndex for Property looping not working #4

Closed
smadhukar2000 opened this issue Aug 6, 2019 · 1 comment
Closed

copyIndex for Property looping not working #4

smadhukar2000 opened this issue Aug 6, 2019 · 1 comment

Comments

@smadhukar2000
Copy link

smadhukar2000 commented Aug 6, 2019

Hi Team,

Seems CopyIndex for property looping is not working again.

Followed below MSDN docs
https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-multiple#property-iteration

similar issue was reported back in 2017

#2

Error

Unable to process template language expressions for resource '/subscriptions/746ac5b9-70eb-4c76-bdf4-0664bfdff2ea/resourceGroups/GRP-EU-IFM-SMA-RG12/providers/Microsoft.Web/sites/aziedt1xvu284/config/web' at line '155' and column '9'. 'The template function 'copyIndex' is not expected at this location. The function can only be used in a resource with copy specified.

Parameter

"allowedCallerIpAddresses": {
"type": "array",
"defaultValue": [
{ "addressRange": "52.232.252.175/32" },
{ "addressRange": "52.236.71.198/32" },
{ "addressRange": "23.101.29.245/32" }
]
}

Resource Code
{
"apiVersion": "2018-02-01",
"dependsOn": [
"[resourceId('Microsoft.Web/sites', variables('functionsHost'))]",
"[resourceId('Microsoft.Web/sites/extensions', variables('functionsHost'), 'MSDeploy')]"
],
"name": "web",
"properties": {
"minTlsVersion": "1.2",
"copy": [
{
"name": "ipSecurityRestrictions",
"count": "[length(parameters('allowedCallerIpAddresses'))]",
"input": {
"ipAddress": "[parameters('allowedCallerIpAddresses')[copyIndex('ipSecurityRestrictions')].addressRange]",
"action": "Allow",
"tag": "Default",
"priority": "100",
"name": "[concat('APIM IPs-', copyIndex('ipSecurityRestrictions'))]",
"description": "Allowed APIM Access only"
}
}
]
},
"type": "config"
}

Note

ipSecurityRestrictions do work with single ip.

{
"type": "config",
"apiVersion": "2018-02-01",
"name": "web",
"dependsOn": [
"[resourceId('Microsoft.Web/sites', variables('functionsHost'))]",
"[resourceId('Microsoft.Web/sites/extensions', variables('functionsHost'), 'MSDeploy')]"
],
"properties": {
"minTlsVersion": "1.2",
"ipSecurityRestrictions": [
{
"ipAddress": "[parameters('allowedCallerIpAddresses')[0].addressRange]",
"action": "Allow",
"tag": "Default",
"priority": "100",
"name": "APIM IPs",
"description": "Allowed APIM Access only"
}
]
}
}

Thanks,
Subhash

@smadhukar2000
Copy link
Author

Thanks, Below solution did worked

it looks like there is something unusual about how copy is working with the config resource type. I suspect it has to do with the config properties also being available on the sites resources. If you move the config setting up to the sites resources, instead of as a sub-resource, it works correctly.

{
"apiVersion": "2018-11-01",
"name": "[parameters('siteName')]",
"type": "Microsoft.Web/sites",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.Web/serverfarms', parameters('hostingPlanName'))]"
],
"properties": {
"serverFarmId": "[parameters('hostingPlanName')]",
"siteConfig":{
"minTlsVersion": "1.2",
"copy": [
{
"name": "ipSecurityRestrictions",
"count": "[length(parameters('allowedCallerIpAddresses'))]",
"input": {
"ipAddress": "[parameters('allowedCallerIpAddresses')[copyIndex('ipSecurityRestrictions')].addressRange]",
"action": "Allow",
"tag": "Default",
"priority": "100",
"name": "[concat('APIM IPs-', copyIndex('ipSecurityRestrictions'))]",
"description": "Allowed APIM Access only"
}
}
]
}

    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant