Open LaszloKoller opened 1 year ago
@LaszloKoller thank you for this, we will review and incorporate in the coming sprints.
@santhoshb-msft We seem to be experiencing the same and this is flagged in a review since the error message is leaking a lot of debug data. Is there a way in the Web App to disable the verbose error message that appears when there is an SQL issue (like 0x80131904).
Describe the bug The CustomerSite (& AdminSite) is unable to recover from a transient failure when connecting to the backing Azure SQL database.
To Reproduce Steps to reproduce the behavior:
Expected behavior
Microsoft.Data.SqlClient.SqlException
should not occur due to transient (connection) failures (see log excerpt below).RESOLUTION: Implement the fix recommended in Microsoft's Connection Resiliency article.
In the AdminSite/Startup.cs file, change the
UseSqlServer()
line of code from:services.AddDbContext<SaasKitContext>(options => options.UseSqlServer(this.Configuration.GetConnectionString("DefaultConnection")));
...to:services.AddDbContext<SaasKitContext>(options => options.UseSqlServer(this.Configuration.GetConnectionString("DefaultConnection"), providerOptions => providerOptions.EnableRetryOnFailure()));
In the CustomerSite/Startup.cs file, change the
UseSqlServer()
line of code from:services.AddDbContext<SaasKitContext>(options => options.UseSqlServer(this.Configuration.GetConnectionString("DefaultConnection")));
...to:services.AddDbContext<SaasKitContext>(options => options.UseSqlServer(this.Configuration.GetConnectionString("DefaultConnection"), providerOptions => providerOptions.EnableRetryOnFailure()));
In the MeteredTriggerJob/Program.cs file, change the
UseSqlServer()
line of code from:.AddDbContext<SaasKitContext>(options => options.UseSqlServer(configuration.GetConnectionString("DefaultConnection")))
...to:.AddDbContext<SaasKitContext>(options => options.UseSqlServer(configuration.GetConnectionString("DefaultConnection"), providerOptions => providerOptions.EnableRetryOnFailure()))
Screenshots Application Insights log excerpt:
Environment (please complete the following information):
No
Windows 11 Pro
5.1.22621.963
Additional context For additional context, see Microsoft's Connection Resiliency article.