I have a generic ASP.NET Core Web API that uses EF Core to connect to a SQL Server instance that uses Microsoft Entra MFA account.
The connectivity prompt for the SQL Server looks like this:
I have no problem connecting to this database locally using the following connection string and the code:
string connectionString = "Server=tcp:some-server.database.windows.net,1433;Authentication=Active Directory Interactive;Database=some-database;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;";
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder.UseSqlServer(connectionString, builder =>
{
builder.EnableRetryOnFailure(5, TimeSpan.FromSeconds(10), null);
});
However, every time I connect locally, a browser opens with a prompt where I have to enter my password.
Obviously, that mode won't work once I deploy the app into an App Service or a container.
I know that I have to use a secret token and add Service Principal as SQL Server user somehow.
I have generated Service Principal Name, Secret, Application (Client) ID, Tenant ID, Subscription ID, Object ID, and the Directory ID.
How do I generate a proper connection string for this connection and what other steps I should take to properly deploy the app?
Thank you very much in advance

Authentication=Active Directory Service Principalyet? Ref: Connect to Azure SQL with Microsoft Entra authentication and SqlClient