简体   繁体   中英

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. 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. 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. Also viewed the environmental variables and there is no ASPNETCORE_* vars set.

At a loss of what else to try.

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.

What worked for me was using the Azure portal, instead of the Azure DevOps portal, to set up the build and release pipelines.

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. Among the options you will find Azure Pipelines (Preview). Following the wizard should create a new build and release pipelines in your Azure DevOps project, and will also trigger them.

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.

Upon a quick look, both pipelines look exactly the same as those I created manually, but what can you do!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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