Remove property from ARM Template when it's not needed

Viewed 329

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?

0 Answers
Related