我正在使用 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);
}
答案 0 :(得分:0)
我认为你的循环在它从服务获取所有数据之前关闭时没有正常运行,请检查它。