Azure文件共享创建目录

时间:2017-12-14 20:36:47

标签: azure azure-storage-files

我正在审核Azure文件共享服务。我想确定创建目录所需的内容。没有明确的配置此类活动 - 所以我只是尝试运行测试场景来创建目录。该目录将在根目录下创建。使用代码:

CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connect);
CloudFileClient fileClient = storageAccount.CreateCloudFileClient();

CloudFileShare fileShare = fileClient.GetShareReference("fileaccess");
if (fileShare.Exists())
{
   CloudFileDirectory rootDirectory = fileShare.GetRootDirectoryReference();
   if (rootDirectory.Exists())
   {                        
     CloudFileDirectory customDirect = 
         rootDirectory.GetDirectoryReference("TEST");
     if (!customDirect.Exists())
     {
        rootDirectory.Create();
     }
   }
}

结果是以下错误:

  
    
      
        

远程服务器返回错误:(405)方法不允许。<<<<

      
    
  

我认为它是Azure上的一个配置 - 但我无法看到Azure上的哪个位置我可以允许此操作。

彼得

1 个答案:

答案 0 :(得分:0)

  

远程服务器返回错误:(405)Method Not Allowed

根本原因:

我确信代码行rootDirectory.Create();中发生405错误。 Azure不允许我们创建根目录,因此Azure服务器不接受它。

<强>解决方案:

根据您的代码逻辑,您似乎想要创建 customDirect ,因此请更改以下代码:

if (!customDirect.Exists())
{
   customDirect.Create();
}
相关问题