RHarris
RHarris

Reputation: 11187

Azure Web App and .NetCore WebAPI - Missing web.config

From what I understand .NetCore no longer uses/needs web.config -- opting instead for appsettings.json.

I have a .NetCore WebAPI that I am trying to host in an Azure WebApp. I've published the API to the WebApp but I keep getting a 500 error. Looking in the Application logs, I can see that the error is:

IIS was not able to access the web.config file for the web site or application.

I'm confused. If .NetCore uses appsettings.json instead of web.config and Azure won't work without web.config, how is one supposed to host a .NetCore app in Azure?

UPDATE

I now realize that this has nothing to do with web.config thanks to @joey-cai pointing me in the right direction.

It appears that Azure did not like my attempt to use Azure Active Directory Authentication in my Connection String. I changed my connection string to simply use SQL Authentication and everything worked. So I guess my question now is, how do I use AAD Authentication for my connection string rather than SQL Authentication.

This SO thread seems to indicate that my connection string was indeed set up correctly for AAD authentication, but I was getting the error:

Keyword not supported: 'authentication' 

whenever I used the connection string like so:

Server=tcp:dbname.database.windows.net,1433;Initial Catalog=dbnamesqldb;Persist Security Info=False;User ID={your_username};Password={your_password};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Authentication="Active Directory Password";

Since the question has now changed, I'm going to create a new post with the new question.

Upvotes: 0

Views: 3294

Answers (1)

Joey Cai
Joey Cai

Reputation: 20067

does this mean I must have we.config? If so, can it just be an empty file?

When you deploy the .net core project to Azure, you could go to https://xxxxx.scm.azurewebsites.net and click Debug console> CMD > site > wwwroot > web.config. The web.config will be there.

Try to delete the site in azure and recreat the site in azure. Also, try to run the application that you are deploying by running dotnet MyApp.dll and making sure that works. You need more details as to why it’s having an application issue. This might help. Also consider testing using a self contained application. Also try installing the asp.net core extension on the azure app service.

For more details, you could refer to Deploy ASP.NET Core apps to Azure App Service.

Upvotes: 1

Related Questions