Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/263.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# CloudBlobContainer.Exists()将挂起/超时_C#_Azure_Blob - Fatal编程技术网

C# CloudBlobContainer.Exists()将挂起/超时

C# CloudBlobContainer.Exists()将挂起/超时,c#,azure,blob,C#,Azure,Blob,出于某种原因,调用.Exists(),.CreateIfNotExists()和.Create()将挂起并且永远不会返回。我并没有收到超时异常,我只是想人们可能会搜索这个词 具体代码如下: var container = _blobClient.GetContainerReference("report_dunderMifflin_details"); container.CreateIfNotExists(BlobContainerPublicAccessType.Off); //alte

出于某种原因,调用
.Exists()
.CreateIfNotExists()
.Create()
将挂起并且永远不会返回。我并没有收到超时异常,我只是想人们可能会搜索这个词

具体代码如下:

var container = _blobClient.GetContainerReference("report_dunderMifflin_details");

container.CreateIfNotExists(BlobContainerPublicAccessType.Off);

//alternatively, because I know it doesn't exist yet
//I can just call Create and it will hang too
container.Create();

我尝试通过Azure门户手动创建相同的容器(
report\u dunderMifflin\u details
),但出现了一个异常,显示:

容器名称只能包含字母、数字和连字符,并且必须为小写。名称必须以字母或数字开头。名称不能包含两个连续连字符

一旦我将容器名称从
report\u dunderMifflin\u details
更改为
report dunderMifflin details
,它就工作得很好。令人失望的是,Windows.AzureStorage类中没有引发异常

编辑1:

在已经存在的容器上调用
Create()。瘸子

编辑2:

我已经开始在Azure SDK上编写一个facade,这样它就不太复杂了,并且实现了一个用于模拟/测试的接口。我将这个助手方法添加到facade中,以检查提议的容器名称是否有误

private void CheckContainer(string containerName)
{
    var invalidNameMessage = "Container names can contain only letters, numbers, and hyphens and must be lowercase. The name must start with a letter or a number. The name can't contain two consecutive hyphens.";

    var anyInvalidChars = new Regex("[^0-9a-z-]");
    if (anyInvalidChars.IsMatch(containerName))
        throw new ArgumentException(invalidNameMessage);

    var startsWithHyphen = new Regex("$-");
    if (startsWithHyphen.IsMatch(containerName))
        throw new ArgumentException(invalidNameMessage);

    var twoHyphens = new Regex("--");
    if (twoHyphens.IsMatch(containerName))
        throw new ArgumentException(invalidNameMessage);
}