【问题标题】:Azure blob client set shorter timeoutAzure Blob 客户端设置更短的超时
【发布时间】:2017-08-07 13:26:11
【问题描述】:

我有以下代码:

private static CloudBlobClient GetClient()
{
    var account = CloudStorageAccount.Parse(Settings.Deployment.AzureConnectionString);
    return account.CreateCloudBlobClient();
}

当 blob 客户端不存在并抛出 No connection could be made because the target machine actively refused it 时,它需要的时间太长(我相信大约一分钟左右)。

如何将超时时间缩短到 5 秒左右?

【问题讨论】:

  • 您能否描述一下“当 blob 客户端不存在时”的含义?

标签: c# asp.net azure timeout azure-blob-storage


【解决方案1】:

据我所知,它不会向 Azure 存储服务器发送请求,而我们只是调用 CloudStorageAccount.CreateCloudBlobClient() 方法来创建 Blob 服务客户端。它只是创建一个 Blob 服务客户端并使用您提供的存储信息(连接字符串)来配置它。在我看来, CloudStorageAccount.CreateCloudBlobClient() 不应该导致超时问题,也许程序中的另一个代码 sn-p 会导致问题。

Azure 存储客户端库的源代码在 GitHub,您可以找到 CreateCloudBlobClient() 的源代码。

/// <summary>
/// Creates the Blob service client.
/// </summary>
/// <returns>A <see cref="CloudBlobClient"/> object.</returns>

public CloudBlobClient CreateCloudBlobClient()
{
    if (this.BlobEndpoint == null)

    {

        throw new InvalidOperationException(SR.BlobEndPointNotConfigured);

    }
    return new CloudBlobClient(this.BlobStorageUri, this.Credentials);
}

【讨论】:

    猜你喜欢
    • 2019-03-21
    • 2022-01-07
    • 1970-01-01
    • 2011-03-09
    • 1970-01-01
    • 2011-12-24
    • 2011-07-11
    • 2014-03-01
    • 1970-01-01
    相关资源
    最近更新 更多