2

I'm deploying an application gateway with ARM Template and wants to loop through the creation of listeners. This is how far I got:

"copy": [
                {
                    "name": "httpListeners",
                    "count": "[length(parameters('APPLICATIONS'))]",
                    "input": {
                        "name": "[concat(parameters('APPLICATIONS')[copyIndex('httpListeners')].site,'-',parameters('APPLICATIONS')[copyIndex('httpListeners')].protocol,'listener')]",
                        "properties": {
                            "FrontendIPConfiguration": {
                                "Id": "[concat(variables('applicationGatewayID'), '/frontendIPConfigurations/', variables('frontendIpConfigName'))]"
                            },
                            "FrontendPort": {
                                "Id": "[concat(variables('applicationGatewayID'), '/frontendPorts/', variables('frontendPortName443'))]"
                            },
                            "Protocol": "[parameters('APPLICATIONS')[copyIndex('httpListeners')].protocol]",
                            "SslCertificate": {
                                "Id": "[parameters('APPLICATIONS')[copyIndex('httpListeners')].cert]"
                            },
                            "HostName": "[parameters('APPLICATIONS')[copyIndex('httpListeners')].site]",
                            "RequireServerNameIndication": "[if(equals(parameters('APPLICATIONS')[copyIndex('httpListeners')].protocol, 'HTTPS'), json('true'), json('false'))]"
                        }
                    }
                }
            ]

It works well as long as I only create HTTPS listeners, but when I create a HTTP listener I want to get rid of this part:

"SslCertificate": {
                            "Id": "[parameters('APPLICATIONS')[copyIndex('httpListeners')].cert]"
                        }

Just setting the parameter parameters('APPLICATIONS')[copyIndex('httpListeners')].cert to null doesn't help.

Any suggestions?

Santa
  • 71
  • 7
  • Does this answer your question? [Is it possible to have conditional property in ARM template](https://stackoverflow.com/questions/53876482/is-it-possible-to-have-conditional-property-in-arm-template) just the other way around – 4c74356b41 Feb 24 '21 at 13:48
  • Not really... His solution ends up with this: `"licenseType": "[if(variables('isWindowsOS'), 'Windows_Server', json('null'))]"` But that doesn't remove the property `licenseType`, it just sets it to null. I've already tried that and it doesn't work. – Santa Feb 24 '21 at 14:09
  • @4c74356b41, you helped me out in an other case about subnet and gave me this code to have the opportunity to choose to have a route table associated to subnet or not: `"routeTable": "[if(equals(parameters('VNET')[copyIndex('Vnets')].Subnets[copyIndex('subnets')].routeTable, json('null')), json('null'), json(concat('{\"id\": \"', resourceId('Microsoft.Network/routeTables', parameters('VNET')[copyIndex('Vnets')].Subnets[copyIndex('subnets')].routeTable), '\"}')))]"` Not sure though how to transform the code to fit in this case – Santa Feb 24 '21 at 15:07
  • how about you look at my answer, not whatever the OP is doing. it talks about your case specifically – 4c74356b41 Feb 24 '21 at 15:28

0 Answers0