Azure 文件存储中是否有我可以访问的根文件夹?

Is there a root folder I can access in Azure File Storage?

我正在从 Silverlight 访问 Azure 文件存储,我需要 upload/create 在存储的根目录下创建一个 crossdomain.xml 文件:

https://[account].file.core.windows.net/crossdomain.xml

看到很多关于 blob 的示例,但我似乎无法为文件存储创建 $root(不添加文件共享)。

Silverlight 需要根级别的 crossdomain.xml 才能使用 Azure REST API。

有什么想法吗?

A​​zure 文件存储 follows the "share-directory" structure。我不知道 Azure 文件存储中的任何根文件夹(我知道跨域和要求),我相信它不能用文件存储来完成。

您可以调用

CloudFileDirectory rootDir = share.getRootDirectoryReference() 

其中 returns 共享根目录,但不是文件存储目录。

为了能够实现您的需求,如果没有需要文件存储的特定要求,我建议您切换到 Blob 存储。

评论区不允许那么多字符。因此,我将其作为答案发布,但实际上并不是解决方案:)。

以下是我想分享的经验。

我尝试将跨域文件添加到根目录中,但未能成功。代码如下:

CloudStorageAccount storageAccount = CloudStorageAccount.Parse(getConnectionString());

CloudFileClient client = storageAccount.CreateCloudFileClient();
CloudFileShare share = client.GetShareReference(shareName);
CloudFileDirectory rootDir = share.GetRootDirectoryReference();

var crossDomainFile = share.GetRootDirectoryReference().GetFileReference("crossdomain.xml");

if (!crossDomainFile.Exists())
{
    crossDomainFile.UploadText(getCrossDomainXmlContent());
    Console.WriteLine("crossDomainFile.StorageUri:" + crossDomainFile.StorageUri.PrimaryUri);
}

share.GetRootDirectoryReference().GetFileReference("crossdomain.xml") 给你这个地址: https://[account].file.core.windows.net/<share姓名>/crossdomain.xml.

对于 Silverlight 或 Flash 客户端,文件必须位于 https://[account].file.core.windows.net/crossdomain.xml

似乎使用 blob 存储而不是文件是更好的选择。

同样通过给一个像https://[account].file.core.windows.net/crossdomain.xml这样的URI来创建一个云文件对象也是没有用的。当您调用 UploadText 方法时(示例:crossDomainFile.UploadText(getCrossDomainXmlContent()),您会收到 400 - Bad Request 错误。