我将尝试使用 Azure Blob 存储。我成功上传了一些图像,但突然出现了以下错误:
实际引发异常的代码为:
我对此进行了调查,发现只要尝试检查 blob 容器是否存在,就会抛出异常。以下是我的代码:BlobClient获取器属性:(请注意,我已经用 ** 标记出连接字符串中的敏感数据)An existing connection was forcibly closed by the remote host
static string connectionString = "DefaultEndpointsProtocol=https;AccountName=**;AccountKey=**;BlobEndpoint=https://**.blob.core.windows.net/;TableEndpoint=https://**.table.core.windows.net/;QueueEndpoint=https://**.queue.core.windows.net/;FileEndpoint=https://**.file.core.windows.net/";
public static CloudBlobClient BlobClient
{
get
{
// Retrieve storage account from connection string.
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);
// Create the blob client.
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
return blobClient;
}
}
实际引发异常的代码为:
CloudBlobContainer container = BlobClient.GetContainerReference(containerName);
if (!container.Exists())
准确地说,异常发生在我检查容器是否存在的那一行。
我不知道出了什么问题。我确定连接字符串是正确的(我复制了它)。
如果有人能告诉我可能出现的问题,我会非常感激。