How do you publish a web app using Azure pipe line?

Deej 21 Reputation points

In Visual Studio (2019) I can build my app and publish it locally. I can then copy the files manually to my server and everything is fine.

I amusing C# Asp.Net-Mvc Core 2.2, I'll be moving to 3.1 shortly but would like to solve this before I move on.

I'm trying to set up an Azure pipeline as I use VSTS-GIT for my source control. My YAML file is below.

The pipeline runs fine and it uploads files to my server but the website doesn't work and the files that are uploaded aren't the same as the manual method. The error is HTTP Error 500.31 - Failed to load ASP.NET Core runtime, but I think that's a red-herring because the exact same website works perfectly fine if I upload files manually.

I've been at this a while now, reading all sorts of articles and videos but I can't seem to get it to work. I know I am doing something wrong but I don't know what.

I'm struggling to find the right details to do the same thing with Azure Dev Ops, can anyone help, please?

    - local-1

      vmImage: 'ubuntu-latest'

      buildConfiguration: 'Release'

    - script: dotnet build --configuration $(buildConfiguration)
      displayName: 'dotnet build $(buildConfiguration)'

    - task: DotNetCoreCLI@2
      displayName: Publish
        command: publish
        publishWebProjects: True
        arguments: '--configuration $(BuildConfiguration) --output $(build.artifactstagingdirectory)'
        zipAfterPublish: false

    - task: FtpUpload@2
        credentialsOption: 'inputs'
        serverUrl: ''
        username: 'xxxxxxxxxxxxx'
        password: 'xxxxxxxxxx'
        rootDirectory: '$(Build.ArtifactStagingDirectory)'  
        filePatterns: '**'
        remoteDirectory: '/'
        clean: false
        cleanContents: false
        preservePaths: false
        trustSSL: false
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,997 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. SUNOJ KUMAR YELURU 13,956 Reputation points MVP


    Check on the below link it helps on above error.
    Troubleshoot ASP.NET Core on Azure App Service and IIS

    Please don’t forget to Accept the answer and up-vote wherever the information provided helps you, this can be beneficial to other community members.

    0 comments No comments

  2. Krish G 2,326 Reputation points

    The error 500.31 happens due to below as mentioned in 500.31 ANCM Failed to Find Native Dependencies, you can find the detailed error in the http response by setting the ASPNETCORE_ENVIRONMENT environment variable to Development.


    The worker process fails. The app doesn't start.

    The ASP.NET Core Module attempts to start the .NET Core runtime in-process, but it fails to start. The most common cause of this startup failure is when the Microsoft.NETCore.App or Microsoft.AspNetCore.App runtime isn't installed. If the app is deployed to target ASP.NET Core 3.0 and that version doesn't exist on the machine, this error occurs. An example error message follows:

       The specified framework 'Microsoft.NETCore.App', version '3.0.0' was not found.  
         - The following frameworks were found:  
             2.2.1 at [C:\Program Files\dotnet\x64\shared\Microsoft.NETCore.App]  
             3.0.0-preview5-27626-15 at [C:\Program Files\dotnet\x64\shared\Microsoft.NETCore.App]  
             3.0.0-preview6-27713-13 at [C:\Program Files\dotnet\x64\shared\Microsoft.NETCore.App]  
             3.0.0-preview6-27714-15 at [C:\Program Files\dotnet\x64\shared\Microsoft.NETCore.App]  
             3.0.0-preview6-27723-08 at [C:\Program Files\dotnet\x64\shared\Microsoft.NETCore.App]  

    The error message lists all the installed .NET Core versions and the version requested by the app. To fix this error, either:

    • Install the appropriate version of .NET Core on the machine.
    • Change the app to target a version of .NET Core that's present on the machine.
    • Publish the app as a self-contained deployment.

    When running in development (the ASPNETCORE_ENVIRONMENT environment variable is set to Development), the specific error is written to the HTTP response. The cause of a process startup failure is also found in the Application Event Log.


    So, it looks like when you are building and publishing from local Visual Studio, the dependencies are satisfied. But when doing that from Azure Pipeline dotnet build, something is missing. It can also happen if the application pool does not have permissions to the site folder.
    Related threads:

    On a side note (not related to this issue), if you deploy to Azure App Service (Web App), use Azure App Service Deploy task instead of FTP upload.

    0 comments No comments