通过Bicep部署Azure Web App未正确设置.NET 7运行时堆栈
解决Azure Web App通过Bicep配置ASP.NET Core 7.0的问题
你当前配置里的netFrameworkVersion仅针对传统.NET Framework应用,ASP.NET Core作为跨平台框架,需要根据Web App的操作系统类型补充对应配置,才能正确设置.NET 7运行时:
1. Windows宿主场景
需添加windowsFxVersion配置,与netFrameworkVersion配合使用:
netFrameworkVersion: 'v7.0' windowsFxVersion: 'ASP.NET V7.0' requestTracingEnabled: true remoteDebuggingEnabled: true remoteDebuggingVersion: 'VS2022' httpLoggingEnabled: true use32BitWorkerProcess: false ftpsState: 'FtpsOnly' managedPipelineMode: 'Integrated'
2. Linux宿主场景
需添加linuxFxVersion配置,此时netFrameworkVersion可移除(Linux不支持.NET Framework):
linuxFxVersion: 'DOTNETCORE|7.0' requestTracingEnabled: true remoteDebuggingEnabled: true remoteDebuggingVersion: 'VS2022' httpLoggingEnabled: true use32BitWorkerProcess: false ftpsState: 'FtpsOnly' managedPipelineMode: 'Integrated'
额外兜底配置(若上述设置仍不生效)
可在siteConfig下补充metadata节点,明确指定运行时栈:
metadata: [ { name: 'CURRENT_STACK' value: 'dotnetcore' } ]
关键注意点
- 必须保证Web App服务计划的操作系统(Windows/Linux)与配置的FxVersion字段匹配,否则配置不会生效。
- ASP.NET Core和.NET Framework的配置字段不通用,不要混淆使用。
内容的提问来源于stack exchange,提问作者Adam
相关产品推荐
相关产品推荐

