如何通过Bicep将Azure App Service的Allow public access设为false
在Bicep中设置Azure App Service的"允许公共访问"为false
要禁用Azure App Service的公共网络访问,你需要在Bicep模板的App Service资源siteConfig块中配置publicNetworkAccess属性,将其值设为'Disabled',具体代码示例如下:
// 定义应用服务计划(若已有可省略) resource appServicePlan 'Microsoft.Web/serverfarms@2023-01-01' = { name: 'your-appservice-plan' location: resourceGroup().location sku: { name: 'B1' tier: 'Basic' } } // 定义App Service并禁用公共访问 resource appService 'Microsoft.Web/sites@2023-01-01' = { name: 'your-target-appservice' location: resourceGroup().location properties: { serverFarmId: appServicePlan.id siteConfig: { publicNetworkAccess: 'Disabled' // 此配置对应"允许公共访问"设为false // 可添加其他站点配置,如.NET版本、HTTP版本等 netFrameworkVersion: 'v6.0' http20Enabled: true } } }
部署该模板后,你的App Service会拒绝所有公共网络请求,仅允许通过专用端点访问。若后续需要恢复公共访问,只需将publicNetworkAccess的值改为'Enabled'即可。
内容的提问来源于stack exchange,提问作者StormRider01
相关产品推荐
相关产品推荐

