gpt4 book ai didi

azure - 为 ARM 模板中的所有可能的出站 Ip 地址配置防火墙规则

转载 作者:行者123 更新时间:2023-12-02 06:44:48 24 4
gpt4 key购买 nike

我想创建防火墙规则,以便只有我的 Azure Web 应用程序可以连接到我的数据库。如果可能的话,我想在我的 ARM 模板中执行此操作。这是我到目前为止所尝试过的:

{
"variables": {
"defaultResourceName": "[resourceGroup().name]",
},
"resources": [
{
"type": "Microsoft.Web/sites/firewallRules",
"name": "[concat('AllowAzureIpAddress', copyIndex()",
"apiVersion": "2015-05-01-preview",
"properties": {
"startIpAddress": "[reference('Microsoft.Web/sites', variables('defaultResourceName')).possibleOutboundIpAddresses[copyIndex()]]",
"endIpAddress": "[reference('Microsoft.Web/sites', variables('defaultResourceName')).possibleOutboundIpAddresses[copyIndex()]]"
},
"dependsOn": [
"[resourceId('Microsoft.Sql/servers/', toLower(variables('defaultResourceName')))]"
],
"copy": {
"name": "firewallRuleCopy",
"count": "[length(reference('Microsoft.Web/sites', variables('defaultResourceName')).possibleOutboundIpAddresses)]"
}
},
]
}

主要问题是获取PossibleOutboundIpAddresses。我不确定它们是否可供我使用,当我尝试验证 ARM 模板时,我收到错误消息,提示 此位置不需要模板函数“引用”。请参阅 https://aka.ms/arm-template-expressions 了解使用详细信息..

是否有人做过此操作,对如何获取这些 OutboundIpAddress 有任何建议(最好在列表中,以便副本可以使用它们)?

最佳答案

您的问题不是来自以错误的方式使用引用函数,而是来自以下事实:您无法在复制属性中使用引用函数(复制在“编译时”评估,而引用在运行时评估,因此它无法评估引用的长度复制)。您可能的解决方法是:嵌套部署。这是我一直在使用的:

{
"name": "firewallRules",
"type": "Microsoft.Resources/deployments",
"apiVersion": "2015-01-01",
"properties": {
"mode": "Incremental",
"templateLink": {
"uri": "https://paste.ee/d/Hkebg/0",
"contentVersion": "1.0.0.0"
},
"parameters": {
"prefix": {
"value": "[variables('prefix')]"
},
"iterator": {
"value": "[split(reference(concat(parameters('prefix'), '-', parameters('webAppNames').name), '2016-03-01', 'Full').properties.possibleOutboundIpAddresses, ',')]"
}
}
}
},

关于azure - 为 ARM 模板中的所有可能的出站 Ip 地址配置防火墙规则,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54557812/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com