I have a Linux web app deployed as code
I used to define connection string with the name of the database. The one in use is with dash: myjax-integration
. That connection string consistently returned as empty from configuration manager.
So after figuring the root cause (several hours of pain) I found that the problem is about dash in the name. At the same time, I have another Windows-based web app, where dash works just fine.
And it works on the local computer (Windows). The problem only happens on the cloud.
I created 2 connection strings for testing:
And log them on startup.
var builder = WebApplication.CreateBuilder(args);
builder.Configuration.AddEnvironmentVariables();
.....
var app = builder.Build();
var logger = app.Services.GetRequiredService<ILogger<object>>();
logger.LogInformation($"connection string myjax-integration:[{builder.Configuration.GetConnectionString("myjax-integration")}]");
logger.LogInformation($"connection string myjax_integration:[{builder.Configuration.GetConnectionString("myjax_integration")}]");
And the one with the dash is consistently empty.
I've tried changing the connection name to something else, but as long as there is a dash in it, that name doesn't return the connection string.
As far as I could find, this is nowhere documented. Is it a feature or a bug? If the latter, where is a good place to lodge a bug report?