Reputation: 1293
We have set up an app service project in the Azure Portal and then went through deployment of the project using Visual Studio DevOps. When I go to http://MyAzureSite.azurewebsites.net (Made up URL here), I can confirm that the service is up and running.
But when I add "api/ControllerName/getStatus", I get a 404 error.
Call from my local machine is working perfectly fine.
http://localhost:52686/api/status/getStatus
But not:
http://MyAzureSite.azurewebsites.net/api/status/getstatus
Signature for the GetStatus looks good:
[HttpGet]
public List<Status> GetStatus()
Upvotes: 4
Views: 3740
Reputation: 76
We had the same exact problem with the most recent .NET Core 3.1 LTS release. We found multiple things that can cause this problem. Here are our findings:
ControllerBase creates a controller WITHOUT view support. Controller is for view support. We had an API endpoint that couldn't be reached when deployed in Azure if it was extending Controller and it didn't have a view. No errors or anything. Just couldn't reach it.
If you create the App Service / Web App through the Azure Portal, you won't be able to reach any of the endpoints at first. We are not sure why this is, but we figured out how to make it work again. Go to the configuration for the App Service and follow these steps:
Now you should be able to hit your API endpoints again
These were a few problems that we had and the solutions to them. Hopefully, they help you guys out and save you from days of going "We fixed it!" just to have it stop working again for another unknown reason. I'll update this answer as I find more things that break APIs and App Services and as I find solutions to them.
Upvotes: 3
Reputation: 1293
We had to rebuild the project properly again, its the way project was created that was incorreect.
Upvotes: 1