[英]Azure Application gateway ARM template issue with pickHostNameFromBackendAddress and hostname in backendHttpSettingsCollection
Getting issue in ARM template while configuring backendHttpSettingsCollection.配置 backendHttpSettingsCollection 时出现 ARM 模板问题。 I can not use pickHostNameFromBackendAddress for both condition (true, false ), If we select True then it is throwing eror for hostname, I tried applying json('null'), but still it is throwing the same error.
我不能将 pickHostNameFromBackendAddress 用于这两个条件(true,false),如果我们 select True 那么它会为主机名抛出错误,我尝试应用 json('null'),但它仍然抛出相同的错误。
Is there any way we can Implement both condition in same ARM template.有什么办法可以在同一个 ARM 模板中实现这两个条件。
Template:模板:
{
"name": "backendHttpSettingsCollection",
"count": "[length(parameters('backendHttpSettings'))]",
"input": {
"name": "[parameters('backendHttpSettings')[copyIndex('backendHttpSettingsCollection')].name]",
"properties": {
"port": 443,
"pickHostNameFromBackendAddress": "[parameters('backendHttpSettings')[copyIndex('backendHttpSettingsCollection')].pickHostNameFromBackendAddress]",
"hostName": "[if(parameters('backendHttpSettings')[copyIndex('backendHttpSettingsCollection')].pickHostNameFromBackendAddress, json('null') , parameters('backendHttpSettings')[copyIndex('backendHttpSettingsCollection')].hostName)]",
"protocol": "Https",
"probeEnabled": "[parameters('backendHttpSettings')[copyIndex('backendHttpSettingsCollection')].probeEnabled]",
"probe": {
"id": "[resourceId('Microsoft.Network/applicationGateways/probes', parameters('applicationGatewayName'), parameters('backendHttpSettings')[copyIndex('backendHttpSettingsCollection')].probe)]"
}
}
}
},
Parameter:范围:
{
"name": "https-test1",
"hostName": "",
"probeEnabled": true,
"pickHostNameFromBackendAddress": true,
"probe": "slash-probe1"
},
Thanks谢谢
I can reproduce the same error.我可以重现同样的错误。 It cannot pass the template validation even if the null or blank value is assigned to
hostName
.即使将 null 或空值分配给
hostName
也无法通过模板验证。
As a workaround, You can have a try wrapping all the properties in a parameter object. Define two object parameters for the true and false scenario.作为解决方法,您可以尝试将所有属性包装在参数 object 中。为 true 和 false 场景定义两个 object 参数。 See below example:
请参阅以下示例:
"parameters": {
"pick": {
"type": "bool",
"defaultValue": true
},
"host": {
"type": "string",
"defaultValue": "leviCustom.com"
},
"pickFalse":{
"type": "object",
"defaultValue":{
"port": 443,
"protocol": "Https",
"cookieBasedAffinity": "Disabled",
"hostName": "[parameters('host')]",
"pickHostNameFromBackendAddress": false,
"requestTimeout": 20
}
},
"pickTrue":{
"type": "object",
"defaultValue":{
"port": 443,
"protocol": "Https",
"cookieBasedAffinity": "Disabled",
"pickHostNameFromBackendAddress": true,
"requestTimeout": 20
}
}
},
"backendHttpSettingsCollection": [
{
"name": "LeviHttpSetting",
"properties": "[if(parameters('pick'),parameters('pickTrue'),parameters('pickFalse'))]"
}
taken Properties as variable like below:将属性作为变量,如下所示:
"copy": [
{
"name": "backendHttpSettingsCollectionWithHost",
"count": "[length(parameters('backendHttpSettings'))]",
"input": {
"name": "[parameters('backendHttpSettings')[copyIndex('backendHttpSettingsCollectionWithHost')].name]",
"properties": {
"port": 443,
"hostName": "[parameters('backendHttpSettings')[copyIndex('backendHttpSettingsCollectionWithHost')].hostname]",
"protocol": "Https",
"probeEnabled": "[parameters('backendHttpSettings')[copyIndex('backendHttpSettingsCollectionWithHost')].probeEnabled]",
"probe": {
"id": "[resourceId('Microsoft.Network/applicationGateways/probes', parameters('applicationGatewayName'), parameters('backendHttpSettings')[copyIndex('backendHttpSettingsCollectionWithHost')].probe)]"
}
}
},
{
"name": "backendHttpSettingsCollectionWithoutHost",
"count": "[length(parameters('backendHttpSettings'))]",
"input": {
"name": "[parameters('backendHttpSettings')[copyIndex('backendHttpSettingsCollectionWithoutHost')].name]",
"properties": {
"port": 443,
"pickHostNameFromBackendAddress": "[parameters('backendHttpSettings')[copyIndex('backendHttpSettingsCollectionWithoutHost')].pickHostNameFromBackendAddress]",
"protocol": "Https",
"probeEnabled": "[parameters('backendHttpSettings')[copyIndex('backendHttpSettingsCollectionWithoutHost')].probeEnabled]",
"probe": {
"id": "[resourceId('Microsoft.Network/applicationGateways/probes', parameters('applicationGatewayName'), parameters('backendHttpSettings')[copyIndex('backendHttpSettingsCollectionWithoutHost')].probe)]"
}
}
}
}
and used in application gateway properties as below:并在应用程序网关属性中使用如下:
"backendHttpSettingsCollection": "[if(variables('pickHostNameFromBackendAddress')[0], variables('backendHttpSettingsCollectionWithoutHost') , variables('backendHttpSettingsCollectionWithHost'))]",
this is working for both conditions这适用于两种情况
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.