This is the closest post I could find that relates to my issue. Hope you don't mind my piggy-backing.
My connection string works in VS Code but breaks in Azure with the following error:
ManagedIdentityCredential authentication failed: Service request failed.
My connectionstring looks like:
Server=tcp:asi-sql-dev.database.windows.net,1433;Initial Catalog=anabelle;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;Authentication='Active Directory Default'
and when configuring EF Core I do the following:
var connectionString = string.Empty;
if (builder.Environment.IsDevelopment())
{
connectionString = builder.Configuration.GetConnectionString("AzureSQL");
}
else
{
connectionString = Environment.GetEnvironmentVariable("AzureSQL");
}
builder.Services.AddDbContext<DataContext>(options =>
{
options.UseSqlServer(connectionString);
});
What am I missing?
I have tried multiple workarounds and looked at several posts. The closest I can get to is Microsoft.Data.SqlClient.SqlException (0x80131904): ManagedIdentityCredential authentication failed: Service request failed
When changing the connection string to normal UN / PW it works in Azure.