skip to Main Content

I have an ASP.NET Core Web API that I’ve been running on Azure App Service Windows platform. This app was targeting .NET 7 and today I updated it to target .NET 8. It compiles and runs fine locally.

According to this announcement, .NET 8 is now available on Azure App Service: https://azure.github.io/AppService/2023/11/14/dotnet8-ga.html

I deployed the app to Azure App Service and then changed the .NET version to .NET 8 — see below:

enter image description here

This didn’t work and I kept getting the following error:

ANCM Failed to Find Native Dependencies

I then found this post on Reddit: https://www.reddit.com/r/dotnet/comments/17v7qb5/http_error_50031_ancm_failed_to_find_native/

So, I went ahead and installed ASP.NET Core .NET 8 x64 and x86 through Kudu under Advanced Tools — see below:

enter image description here

I then stopped and restarted the app on Azure App Service several times and it’s still not working. When I try to hit an endpoint on my API, it spins and spins for a long time and comes back with "Service Unavailable" error but according to app dashboard on Azure, it’s up and running.

Any suggestions? Anyone else is having upgrade to .NET 8 issues?

PS: the deployment of my API app is done through GitHub actions and I did update the .NET version to .NET 8 — see below:

enter image description here

2

Answers


  1. I have created a basic ASP .NET Core Web API with version .NET-8.0 and deployed to Azure App Service using GitHub actions.

    Steps Followed:

    • Created an ASP .NET Core Web API project with .NET 8 version and able to run locally.

    • Modified program.cs:

    var builder = WebApplication.CreateBuilder(args);
    
    builder.Services.AddControllers();
    
    builder.Services.AddEndpointsApiExplorer();
    builder.Services.AddSwaggerGen();
    
    var app = builder.Build();
    
    app.UseDeveloperExceptionPage();
    app.UseSwagger();
    app.UseSwaggerUI(x =>
    {
    
        x.SwaggerEndpoint("/swagger/v1/swagger.json", "Web API V1");
    
    #if DEBUG
        x.RoutePrefix = "swagger"; // For localhost
    #else
        x.RoutePrefix = string.Empty; //  For azure
    #endif
    }
    );
    app.UseHttpsRedirection();
    
    app.UseAuthorization();
    
    app.MapControllers();
    
    app.Run();
    
    
    • Pushed the application to GitHub.
    • Created a Windows Azure App Service with .NET-8.0(Early Access) as run time stack.

    enter image description here

    • Deploying the application to Azure using GitHub Actions.

    My Workflow:

    Below is the workflow I have used to deploy the application.

    name: Build and deploy ASP.Net Core app to Azure Web App - <web_app_name>
    
    on:
      push:
        branches:
          - main
      workflow_dispatch:
    
    jobs:
      build:
        runs-on: windows-latest
    
        steps:
          - uses: actions/checkout@v4
    
          - name: Set up .NET Core
            uses: actions/setup-dotnet@v1
            with:
              dotnet-version: '8.x'
              include-prerelease: true
    
          - name: Build with dotnet
            run: dotnet build --configuration Release
    
          - name: dotnet publish
            run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/myapp
    
          - name: Upload artifact for deployment job
            uses: actions/upload-artifact@v3
            with:
              name: .net-app
              path: ${{env.DOTNET_ROOT}}/myapp
    
      deploy:
        runs-on: windows-latest
        needs: build
        environment:
          name: 'Production'
          url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
        
        steps:
          - name: Download artifact from build job
            uses: actions/download-artifact@v3
            with:
              name: .net-app
          
          - name: Deploy to Azure Web App
            id: deploy-to-webapp
            uses: azure/webapps-deploy@v2
            with:
              app-name: '<web_app_name>'
              slot-name: 'Production'
              package: .
              publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_FXXXXXXXXXX }}
    
    

    Deployment Status:

    enter image description here

    Running the application successfully.

    enter image description here

    If the issue still persists while deploying the application, add --self-contained in dotnet’s publish command in the GitHub workflow.

          - name: dotnet publish
            run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/myapp --self-contained true
    
    Login or Signup to reply.
  2. I have basically the same problem deploying to Azure with .NET Core 8 web app. You can use the ‘self-contained’ as a workaround.
    However, I discovered that if you deploy to ‘East US’ it works fine, but ‘UK South’ produces ‘Service Unavailable’.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search