Web App 间歇性地无法使用 Azure SQL

问题描述

我有一个在 Azure 中运行的 web 应用程序。它使用设置为标准 S0:10 DTU 性能的 Azure MSsql 数据库。后端是用 dot net core 3.1 编写的。当我访问该应用时,它运行良好。

检查我的日志,我发现了其中一些,它们在奇怪的时间间隔几周发生。

Microsoft.Data.sqlClient.sqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to sql Server. The server was not found or was not accessible. Verify that the instance name is correct and that sql Server is configured to allow remote connections. (provider: TCP Provider,error: 35 - An internal exception was caught)

这个错误让我想知道是否某个随机用户无法访问该站点,因为 sql 服务器不会响应。

关于这可能是什么的任何建议? 或者关于我应该尝试做什么的建议?

更新 1: 作为对有关重试的评论的回应。我实际上已经使用此代码在连接(.net 核心实体框架)上实现了重试。

services.AddDbContext<ApplicationDbContext>(
    options =>
    {
        options.UsesqlServer(connectionString,sqlOptions =>
        {
            sqlOptions.EnableRetryOnFailure(
                maxRetryCount: 10,maxRetryDelay: TimeSpan.FromSeconds(10),errorNumbersToAdd: null
            );
        });
        options.EnableSensitiveDataLogging(true);
    },ServiceLifetime.Transient
);

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)