I have a .NET 8 API that I have deployed to Azure App Services - It is a Web App (Linux Container). The API endpoints work except for endpoint that involve a database call. Swagger shows up as expected (as I have configured the app in development mode). However, I cannot seem to configure or change the connection strings via Azure. In my local environment I use user secrets. Here is an extract or example of my appsettings.json file:
{
"Logging": {
"LogLevel": {
"Default": "Error",
"Microsoft": "Warning",
"MyApp.Api": "Information",
"MyApp.Core": "Information"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"SqlConnection": "USER SECRETS"
}
}
In Azure I have configured the Connection strings via:
Settings > Environment variables > Connection strings [tab]
With the following:
[
{
"name": "SqlConnection",
"value": "{MY PRODUCTION CONNECTION STRING HERE}",
"type": "SQLServer",
"slotSetting": false
}
]
I have tried to change the type, between SQLServer, SQLAzure and Custom, but that has no effect.
I have added logging in an attempt to read and display the connection string when I make an API call that involves calling the database. In the logs it displays USER SECRETS so it looks like the connection string that I have applied in the Azure Portal is not being applied.
My original connection string name was Default but I changed that to SqlConnection but that did not work either.
What am I doing wrong, should I be approaching this differently. Docker and Containers always seem to give me headaches.
Help!