可以使用if语句组合实现此功能。以下是一个示例:
resource appsvc 'Microsoft.Web/sites@2021-02-01' = {
name: 'myapp'
location: 'centralus'
kind: 'app'
properties: {
serverFarmId: appPlan.id
}
// Define ipSecurityRestrictions
ipSecurityRestrictions: if(params.addOutboundIp, [
{
ipAddress: appSvcOutboundIp
action: 'Permit'
priority: 100
}
], [])
}
在示例中,定义了一个if语句,通过params.addOutboundIp变量来限制是否添加出站IP地址。如果该变量为true,则添加出站IP地址;否则不添加。在本例中,if语句使用一个包含有一个IP地址限制的数组来添加出站IP地址。如果没有限制的话,数组将为空。
可以使用类似的方法在其他Web应用程序中添加出站IP地址。
下一篇:Bicep中的可选参数