azure - Azure Web App 和 .NetCore WebAPI - 缺少 web.config
问题描述
据我了解,.NetCore 不再使用/需要 web.config——而是选择 appsettings.json。
我有一个尝试在 Azure WebApp 中托管的 .NetCore WebAPI。我已将 API 发布到 WebApp,但我不断收到 500 错误。查看应用程序日志,我可以看到错误是:
IIS was not able to access the web.config file for the web site or application.
我很困惑。如果 .NetCore 使用 appsettings.json 而不是 web.config 并且如果没有 web.config,Azure 将无法工作,那么应该如何在 Azure 中托管 .NetCore 应用程序?
更新
我现在意识到这与 web.config 无关,这要感谢@joey-cai 为我指明了正确的方向。
Azure 似乎不喜欢我在连接字符串中使用 Azure Active Directory 身份验证的尝试。我将连接字符串更改为简单地使用 SQL 身份验证,一切正常。所以我想我现在的问题是,我如何为我的连接字符串使用 AAD 身份验证而不是 SQL 身份验证。
这个 SO 线程似乎表明我的连接字符串确实为 AAD 身份验证正确设置,但我收到错误:
Keyword not supported: 'authentication'
每当我像这样使用连接字符串时:
Server=tcp:dbname.database.windows.net,1433;Initial Catalog=dbnamesqldb;Persist Security Info=False;User ID={your_username};Password={your_password};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Authentication="Active Directory Password";
由于问题现在已经改变,我将使用新问题创建一个新帖子。
解决方案
这是否意味着我必须拥有 we.config?如果是这样,它可以只是一个空文件吗?
当您将 .net 核心项目部署到 Azure 时,您可以转到https://xxxxx.scm.azurewebsites.net
并单击Debug console> CMD > site > wwwroot > web.config.
将web.config
在那里。
尝试在 azure 中删除该站点并在 azure 中重新创建该站点。此外,尝试通过运行dotnet MyApp.dll
并确保其正常运行来运行您正在部署的应用程序。您需要更多详细信息来了解为什么它会出现应用程序问题。这可能会有所帮助。还可以考虑使用自包含应用程序进行测试。还可以尝试在 azure app 服务上安装asp.net 核心扩展。
有关详细信息,您可以参考将ASP.NET Core 应用部署到 Azure 应用服务。
推荐阅读
- javascript - 模态需要有一个 5 秒的计时器并在之后重定向
- python - *_ 和从 Python 中任意长度的迭代中解包元素
- python - 基于可见范围波长的 Matplotlib 颜色图
- amazon-dynamodb - 用于过滤用例的 AppSync DynamoDB 解析器
- django - 类型对象'ProductForm'没有属性'cleaned_data'django
- azure-sql-database - 如何在 Azure WebApp 应用程序中跟踪请求和异常
- google-cloud-platform - GCP - 边缘到边缘路由
- firebase - Firebase Cloud Firestore 读取很久以前从 Firebase 控制台中删除的数据
- reactjs - 为什么渲染成功运行后 react-native 视图不会更新?
- javascript - 淘汰赛:基于选择选项上对象列表属性的警报