简体   繁体   English

.Net 核心容器应用程序显示没有找到 web 地址的网页:https://xyzapp.azurewebsites.net/

[英].Net core container app showing No webpage was found for the web address: https://xyzapp.azurewebsites.net/

I am running .NET Core API on docker and it's working fine on my local machine as I create Azure devops pipelines it is not working on Azure app service showing error I am running .NET Core API on docker and it's working fine on my local machine as I create Azure devops pipelines it is not working on Azure app service showing error

No webpage was found for the web address: https://xyzapp.azurewebsites.net/swagger/index.html HTTP ERROR 404 No webpage was found for the web address: https://xyzapp.azurewebsites.net/swagger/index.html HTTP ERROR 404

When I build the image locally and push it to Azure app service using the same dockerfile it is then working fine.当我在本地构建映像并使用相同的 dockerfile 将其推送到 Azure 应用程序服务时,它就可以正常工作了。

Here are the error logs of api以下是 api 的错误日志

08:45:46 WRN] Failed to determine the https port for redirect. 08:45:46 WRN] 无法确定用于重定向的 https 端口。 [08:45:46 INF] HTTP GET / responded 404 in 162.0077 ms [08:45:46 INF] HTTP GET / 在 162.0077 毫秒内响应 404

Does anyone has idea what's wrong in it, locally build is running and by building Azure devops showing this error有谁知道其中有什么问题,本地构建正在运行,并且通过构建 Azure devops 显示此错误

You can test your webapi directly by postman or browser, it should be working fine.您可以通过 postman 或浏览器直接测试您的 webapi,它应该可以正常工作。

And if your all steps in devops is correct, then you need check your Program.cs file (.Net6).如果你在 devops 中的所有步骤都是正确的,那么你需要检查你的 Program.cs 文件(.Net6)。 If you are using other version, you need check Startup.cs file.如果您使用的是其他版本,则需要检查 Startup.cs 文件。

Then find the IsDevelopment condition, something like below.然后找到IsDevelopment条件,如下所示。

if(app.Environment.IsDevelopment){
    app.UseSwagger();
    app.UseSwaggerUI();
}

Change it to将其更改为

if(app.Environment.IsDevelopment){
    app.UseSwagger();
    app.UseSwaggerUI();
}else{
    app.UseSwagger();
    app.UseSwaggerUI();
}

I think that swagger is generally used for project cooperation or in development mode.我认为swagger一般用于项目合作或开发模式。 The /swagger/index.html page is generally not provided in the production environment, which should be for security.生产环境一般不提供/swagger/index.html页面,应该是出于安全考虑。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM