[英]Asp Core Web App, 404 when deploying with Azure Devops, 200 when publishing via Visual studio
I have a web app that when I publish to an Azure App Service via Visual Studio it works great but when the app is built and published via Azure dev ops (all tasks report success), I get a 404 from the home page. 我有一个Web应用程序,当我通过Visual Studio发布到Azure应用服务时,它工作得很好但是当通过Azure开发构建和发布应用程序(所有任务报告成功)时,我从主页获得404。 I'm just doing a plain publish of the release build.
我只是简单地发布了发布版本。 Nothing funky as far as I can tell.
就我所知,没什么好玩的。
I intially thought it was my WebHost Builder UseUrls call. 我最初认为这是我的WebHost Builder UseUrls调用。 So I changed it:
所以我改变了它:
.UseUrls(new[] { "http://*:44399" }) => .UseUrls(new[] { "http://localhost:44399","http://*:80" })
but that didnt work. 但那没用。
I enabled diagnostic logs on the app service but that didnt show me anything. 我在应用服务上启用了诊断日志,但没有向我显示任何内容。
Using the console on the app service, I can browse to the wwwroot directory and see that the files are being updated by the azure dev ops publish. 使用应用程序服务上的控制台,我可以浏览到wwwroot目录,并查看azure dev ops publish正在更新文件。 Also viewed the environmental variables and there is no ASPNETCORE_* vars set.
还查看了环境变量,并且没有设置ASPNETCORE_ * vars。
At a loss of what else to try. 不知道还有什么可尝试的。
Program.cs Program.cs中
public static IWebHost BuildWebHost(string[] args)
{
return WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseUrls(new[] { "http://localhost:44399","http://*:80" })
.Build();
}
public static void Main(string[] args)
{
BuildWebHost(args).Run();
}
}
Thanks! 谢谢!
I had the same problem, I couldn't get an application deployed via Azure DevOps pipelines to run on Azure AppService. 我遇到了同样的问题,我无法通过Azure DevOps管道部署应用程序以在Azure AppService上运行。
What worked for me was using the Azure portal, instead of the Azure DevOps portal, to set up the build and release pipelines. 对我有用的是使用Azure门户而不是Azure DevOps门户来设置构建和发布管道。
If you create an Azure AppService to host your app via the Azure portal and then go to its Deployment Management section, you will find (as of today) a wizard to create a deployment. 如果您创建Azure AppService以通过Azure门户托管您的应用程序,然后转到其“部署管理”部分,您将找到(截至今天)创建部署的向导。 Among the options you will find Azure Pipelines (Preview).
在这些选项中,您将找到Azure管道(预览)。 Following the wizard should create a new build and release pipelines in your Azure DevOps project, and will also trigger them.
在向导之后,应在Azure DevOps项目中创建新的构建和发布管道,并且还将触发它们。
This made it work from me. 这使它适用于我。
In summary, using the same Azure DevOps project and Azure AppService resource, creating the build and releases pipelines manually from the former didn't work, but creating them automatically following the wizard in the Deployment Management section of the resource on the Azure portal worked. 总之,使用相同的Azure DevOps项目和Azure AppService资源,从前者手动创建构建和发布管道不起作用,但是在Azure门户上的资源的“部署管理”部分中按照向导自动创建它们。
Upon a quick look, both pipelines look exactly the same as those I created manually, but what can you do! 快速浏览一下,两个管道看起来与我手动创建的管道完全相同,但你能做什么!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.