question

PramodValavala-MSFT avatar image
0 Votes"
PramodValavala-MSFT asked ·

[MSDN Redirect] Publishing asp.net Web API to azure app not working? When the API ran locally it works fine.

This is my web api config

     public static void Register(HttpConfiguration config)
     {

         // Web API configuration and services
         // Configure Web API to use only bearer token authentication.
         config.SuppressDefaultHostAuthentication();
         config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));

         // Web API routes
         config.MapHttpAttributeRoutes();


         config.Routes.MapHttpRoute(
             name: "DefaultApi",
             routeTemplate: "api/{controller}/{id}",
             defaults: new { id = RouteParameter.Optional }
         );

When i look on azure at the error log im finding this.

HTTP Error 500.0 - Internal Server ErrorThe page cannot be displayed because an internal server error has occurred.Most likely causes:IIS received the request; however, an internal error occurred during the processing of the request. The root cause of this error depends on which module handles the request and what was happening in the worker process when this error occurred.IIS was not able to access the web.config file for the Web site or application. This can occur if the NTFS permissions are set incorrectly.IIS was not able to process configuration for the Web site or application.The authenticated user does not have permission to use this DLL.The request is mapped to a managed handler but the .NET Extensibility Feature is not installed.Things you can try:Ensure that the NTFS permissions for the web.config file are correct and allow access to the Web server's machine account.Check the event logs to see if any additional information was logged.Verify the permissions for the DLL.Install the .NET Extensibility feature if the request is mapped to a managed handler.Create a tracing rule to track failed requests for this HTTP status code. For more information about creating a tracing rule for failed requests

This error means that there was a problem while processing the request. The request was received by the Web server, but during processing a fatal error occurred, causing the 500 error

Assuming i need to add permissions to the web.config?

Source - MSDN

azure-webapps
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

LouisVital-2259 avatar image
0 Votes"
LouisVital-2259 answered ·

I was the one to originally create this post however I posted it in the wrong place. I managed to find a solution, firstly I was creating a Xamarin login app that connected to the web API I made which then connected to the azure database I made which held all of the user logins. The web API would function locally but when I would host the web API from azure and request from the azure link it would not work. The fix was quite annoying if I must say and I couldn't find the same answer anywhere else, only after hours of checking logs and trying to fix it I found the problem to be a simple setting on azure...

2891-annotation-2020-02-11-100134.png

I had to allow other Azure services to be able to access my Azure-hosted database, simple fix.


· 1 · Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @LouisVital-2259 I'm glad you were able to find your solution. And I'll pass your feedback to our content team so that information like that is more easily discoverable.

EDIT: Here's the doc explaining the solution you found. Either enabling that setting or adding 0.0.0.0 as the start and end IP address to the firewall which is what that option does.

0 Votes 0 · ·