微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决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 举报,一经查实,本站将立刻删除。