I have deployed an ASP.NET Core Web API project using terraform. I can see it has been deployed successfully and the web app service is running. When I browse to the link it returns 404. I was wondering if i can get help on identifying why I am getting 404 error code when it has deployed successfully. I am using the FREE Azure subscription in case it makes difference. Link: https://tigrinyadictionary-api.azurewebsites.net/
Since there is no startup page on web api project, that is why you are getting this error. Let me explain. Ihave created default asp.net web api having weatherforecast. If you run that in your local environment, you will face the same issue of "Resoure not found" as shown in below image.
Now, if I just append the weatherforecast at the end of the URL, it will start working as shown below:-
Above is true for the Azure Deployment as well. I have deployed the same web api on azure, as azure app service and it is showing 404 as shown below:-
Again 404
Now add weatherforecast at end and it will start working and 404 will gone as shown below:-
Remove this configuration WEBSITE_RUN_FROM_PACKAGE
in Azure Portal fixed my issue:
I have tested in my environment and also getting the HTTP 404 error in my ASP. NET Core Web API project after deploy to azure which working fine locally, and then trying some configuration as below,
SOLUTION -1:
In our ASP. net core web API project there was no web.config
file, You can try to add one config file in VS . Go to root of your project>Add>new item>search for config >web configuration file .
And below is the example of code which you can add your own URI and save it in web.config
file .
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\yourURI.dll" stdoutLogEnabled="false" stdoutLogFile="\\?\%home%\LogFiles\stdout" hostingModel="InProcess" />
</system.webServer>
</location>
</configuration>
SOLUTION-2: Make sure that your url in the browser is correct. In some scenario we need to add. Then try to run the Web application . & this is working fine for me . For example:
https://xxxx.azurewebsites.net/api/xxx or, azureAPIurl/api/controllername
For more information please refer this SO Thread : ASP.NET Core Web API runs locally but not on Azure app service & Dev Blogs: 404 response code caused by App Services
© 2022 - 2024 — McMap. All rights reserved.