I am totally new to using Azure services. I've been trying to deploy a C# / ASP.NET Core 7 app I created that relies on Postgres as the database and Entity Framework as ORM.
I used App Services (Linux) to deploy my app from a GitHub Action and the Postgres flexible server as the database.
However my app is unable to load the Connection string I added into the "Settings > Configuration > Connection strings".
Here is the code I use to load it in my Program.cs
file:
// Add services to the container.
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection");
builder.Services.AddDbContext<ApplicationDbContext>(options =>
options.UseNpgsql(connectionString));
builder.Services.AddDatabaseDeveloperPageExceptionFilter();
The app works successfully when used locally w/ docker.
I tried to use Microsoft Key Store but it failed. Also tried to load connection string from env instead of configuration file. Last thing I have done is put into my appsettings.json
a section ConnectionStrings
with a DefaultConnection
and an empty string to it, and that didn't work