【发布时间】:2015-01-14 01:08:09
【问题描述】:
我正在使用 Microsoft.WindowsAzure.StorageClient 从 azure blob 存储中获取图像列表,但出现异常 "Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host"。我该如何解决这个异常。
我的代码:
var azureBlobStorageConnectionString = ConfigurationManager.AppSettings["AzureBlobStorageConnectionString"];
var azureBlobContainerName = ConfigurationManager.AppSettings["AzureBlobContainerName"];
// Retrieve storage account from connection string.
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(azureBlobStorageConnectionString);
// Create the blob client.
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
// Retrieve reference to a previously created container.
CloudBlobContainer container = blobClient.GetContainerReference(azureBlobContainerName);
// Loop over items within the container and output the length and URI.
var containerList = container.ListBlobs().ToList();
ImagesUrls = new List<string>();
foreach (var item in containerList)
{
var blob = (CloudBlockBlob)item;
ImagesUrls.Add(blob.Uri.AbsolutePath);
}
【问题讨论】:
-
关于为什么这不起作用的任何想法?我也遇到了一个非常相似的问题,它在 container.ListBlobs(); 处显示错误;我的容器中也恰好有超过 10K 的 blob。
标签: azure-storage