我正在使用ARM模板部署到Azure Web Apps,该站点部署到许多环境中,ARM模板为每个环境接受不同的参数。
其中一个要求是在某些环境中启用站点上的IP块,但在其他环境中则不启用。这可以通过web.config完成,但这并不理想,因为我通过ARM管理所有应用程序设置,并对zipped站点进行网络部署。为每个环境添加转换将是一件痛苦的事情,并且需要大量的返工。
我想在我们的模板文件中指定这样的东西:
{
"type": "config",
"apiVersion": "2015-08-01",
"name": "web",
"properties": {
"ipSecurityRestrictions": {
"allowUnlisted": false,
"ipAddresses": [ "127.0.0.1", "127.0.0.2" ]
}
},
"dependsOn": [
"[concat('Microsoft.Web/sites/', parameters('nameofwebapp'))]"
]
}
使用resources.azure.com浏览"Microsoft/Web"的资源提供程序,这似乎是可能的,因为"config/Web"上有"ipSecurityRestrictions"属性。
ARMView
ARM资源管理器的代码在这里显示了它,并提示了它的用法。我也可以在这里的.netSDK中找到它的过去用法(用完了允许的链接)。
当我尝试使用resources.azure.com设置时,我没有得到任何反馈,它返回为null。
有人能帮我提供如何使用这处房产的详细信息吗?
该设置用于允许的IP地址,而不是排除-您可以通过https://resources.azure.com/
使用示例为:
"ipSecurityRestrictions": [
{
"ipAddress": "12.23.254.3",
"subnetMask": "255.255.0.0"
}
]
我必须添加siteConfig
并将ipSecurityRestrictions
放置在那里才能使其工作:
{
"apiVersion": "2015-06-01",
"name": "[parameters('siteName')]",
"type": "Microsoft.Web/Sites",
...
"properties":{
"siteConfig":{
"ipSecurityRestrictions" : {
"ipAddress": "123.123.123.123"
}
}
},
"resources" : {
...
}
}
只需在Lars的答案中添加一些内容。对于使用标准逻辑应用程序和Bicep的人来说,这非常相似。
@description('Ip restrictions')
param iprestriction array
resource logicApp 'Microsoft.Web/sites@2022-03-01' = {
name: logicAppName
location: location
kind: 'functionapp,workflowapp'
...
properties: {
httpsOnly: true
serverFarmId: appServicePlan.id
siteConfig: {
ipSecurityRestrictions: iprestriction
appSettings: [
{
name: 'APP_KIND'
value: 'workflowApp'
}
...
]
}
}
}
参数文件看起来像下面的
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"Version": {
"value": "1.0.0"
},
"iprestriction": {
"value": [
{
"ipAddress": "10.0.0.0/24",
"action": "Allow",
"priority": 100
},
{
"ipAddress": "192.168.0.0/24",
"action": "Allow",
"priority": 200
}
]
}
}
}