.Net Core Web API on Azure is not providing API endpoints, only default starter page

Ricky 106 Reputation points
2020-06-15T23:00:18.557+00:00

I've built a simple "Web API" using .Net Core 3.1. Works great locally, and connects to an Azure SQL database. However, when I publish the API to an Azure App Service, I'm unable to figure out where the API is or why it isn't working. Publish is successful. Azure log stream seems to show that the container starts up successfully. However, I only get the default azure web app page, like it was when I first set up the App Service. I've tried checking port 8080, 8081, 5000, 5001, and even 55546/44311 used in IIS Express locally. There is nothing at those ports. When I go to https://[myapp].azurewebsites.net/api/[myendpoint] I just get a 404. I'm at a complete loss and have spent the entire day trying to figure out why this doesn't just work, considering how perfectly it works locally.

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,869 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. ajkuma 22,401 Reputation points Microsoft Employee
    2020-06-17T21:52:42.787+00:00

    Apologies for the delay and any frustration with this issue.

    Just to clarify, are you leveraging Azure App service Windows or Linux app?
    Are you using the default parent base image base or different custom Docker image to run your ap?

    Kindly ensure that the site deployment files are available D:\home\site\wwwroot\ directory. By default, the port 80 and 8080 is accessible (exposed ports).

    Yes, you can simply navigate to http://<app_name>.azurewebsites.net/api/test to see your deployed API.

    Kindly use app setting WEBSITES_PORT to set the port for your own docker image while for blessed images use PORT environment variable as the listening port.

    In your application, please use the PORT or WEBSITES_PORT (as applicable) environment variable as the main web server’s listening port, instead of using a hardcoded port number ( on app start-up on locahost:5000). The PORT environment variable is automatically set by App Service platform at startup time.

    As mentioned, you could try these ways:

    • Use the EXPOSE instruction in your Dockerfile to expose port 5000.
    • Use the WEBSITES_PORT app setting with a value of "5000" to expose that port.

    You can also always inspect the log files from the browser at https://<app-name>.scm.azurewebsites.net/api/logs/docker and leverage App Service diagnostics to fetch more details on the issue. To access App Service diagnostics, navigate to your App Service app in the Azure portal. In the left navigation, click on Diagnose and solve problems- From there, run the “Availability & Performance” & “Diagnostic Tools” for investigation.
    If feasible restart the WebApp and then check to see if that helps.

    Checkout this documentation ‘Tutorial: Host a RESTful API with CORS in Azure App Service’ for a detailed access steps.


  2. martin 1 Reputation point
    2021-06-14T16:47:26.243+00:00

    I'm having the same issue. Do you mean I should not use Code as the "Publish" type?
    I can see files being published to the wwwroot directory. But, the app didn't started.
    I can't see any sign of azure app service running 'dotnet xxx.dll' for my web api.
    Anyone has any idea?

    105378-image.png

    0 comments No comments