简体   繁体   English

使用Azure Devops部署时的Asp Core Web App,404,通过Visual Studio发布时为200

[英]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.

相关问题 .NET Core 3.1 web API 在本地构建良好,但通过 Z3A580F1420psO3psO3973F13ZB0 Dev 部署时出错 - .NET Core 3.1 web API builds fine locally, but gets errors when deploying via Azure DevOps 将带有类库的ASP.Net Core Web App发布到Azure时在主页上出现500错误 - Getting 500 Error on Home page when publishing ASP.Net Core Web App with class library to Azure 发布到Azure时,Visual Studio崩溃 - Visual Studio crashes when publishing to Azure .NET Core应用程序在Visual Studio中的独立发布 - .NET Core app standalone publishing in Visual Studio 通过 vs 发布时为 azure function 选择应用程序名称 - choosing an app name for azure function when publishing via vs 在针对 Azure AD 注销 ASP.NET Core MVC 应用程序时如何修复错误 404? - How to fix error 404 when logging out on an ASP.NET Core MVC app against Azure AD? ASP.NET Core 2.0 Web 应用程序在将项目部署到 Azure Web 服务时失败并出现 SQLite 错误,但在本地环境中运行良好 - ASP.NET Core 2.0 Web Application fails with a SQLite error when deploying the project to Azure Web Service but runs fine in local environment 使用Visual Studio 2012将具有数据库的ASP.net Web应用程序发布到Azure - Publishing ASP.net web application with database to Azure using Visual Studio 2012 尝试从 ASP.NET Core 5 Web 应用程序运行 Api 控制器功能时找不到 404 - 404 not found when trying to run Api Controller function from ASP.NET core 5 web app 在将Xamarin应用程序部署到设备时,Visual Studio 2015有时会冻结 - Visual Studio 2015 sometimes freezes when deploying Xamarin app to device
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM