我正在使用 Azure 存储,在容器上调用命令时遇到了一些问题。我通过单元测试运行它,有时当在容器上调用命令时,它只是坐下来等待该命令近 5 分钟。如果我等待足够长的时间,它将继续并成功。运行它时,容器确实存在,因此根本不必创建容器。
有没有其他人遇到过这个问题?我尝试设置 a ServerTimeout
,BlobRequestOptions
但没有任何影响。
这是我的代码正在执行的操作的示例:
var blobClient = _storageAccount.CreateCloudBlobClient();
var container = blobClient.GetContainerReference(containerName);
var options = new BlobRequestOptions() { ServerTimeout = TimeSpan.FromSeconds(10) };
if (!container.Exists(options)) //<<<<this is where it hangs
{
container.Create();
}
我也试过了CreateIfNotExists()
:
var blobClient = _storageAccount.CreateCloudBlobClient();
var container = blobClient.GetContainerReference(containerName);
container.CreateIfNotExists(); //<<<this is where it hangs
如果我只是尝试列出 blob,它也会挂起
var blobClient = _storageAccount.CreateCloudBlobClient();
var container = blobClient.GetContainerReference(containerName);
container.ListBlobs(); //<<<<this is where it hangs
它不会发生在每个容器上,但是当它发生在一个容器上时,它似乎是同一个容器。我已经检查过,容器确实存在。