0
votes

I have a question regarding asp.NET Core and Azure SQL Database

We can successfully connect to Azure SQL DB via the localhost or VS Debug. I used the same Publish connection string to update the appsettings.json "DefaultConnection". We continue to get an error on Azure URL when trying to login or register. It is not able to connect to the same Azure SQL database successfully.

Also, we get the standard error, which is set correctly in the config files.

Error. An error occurred while processing your request. Development Mode Swapping to Development environment will display more detailed information about the error that occurred. Development environment should not be enabled in deployed applications, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the ASPNETCORE_ENVIRONMENT environment variable to Development, and restarting the application.

Not sure what the issue is with Azure connecting to the database...any help appreciated. To recap, it works with the Azure SQL DB from local host, and the DefaultConnection is the same for both versions.

1
Interesting...even though I published with the correct connection string several times after the initial incorrect string, I noticed in the Azure portal that it never updated and still had the original incorrect connection string password. Updated this in the portal and the site worked. Weird that is didn't update on Publish, but did work in localhost connected to Azure SQL DB. - Justin W. Morris

1 Answers

0
votes

If I recall correctly, the Azure Web Apps do a bit of work under the covers to make it possible to change the connection string from the portal; as a result, it may complicate the process you attempted to use with "publish", as it may not update the key-value pairs that it stores the connection string as. AFAIK, updating/publishing again will update the code, but not the existing values that are in the key-value store.

This is detailed here: how connection strings work in Azure Web Apps