如何从.NET在Azure Data Lake文件共享中创建文件



我一直在尝试在Azure Data Lake Gen2文件共享中创建一个目录。我可以使用下面的代码在同一存储帐户中创建blob容器,而不会出错。

static void Main(string[] args)
{
string storageUri = "https://xxxxxxx.dfs.core.windows.net";
DefaultAzureCredential cred = new DefaultAzureCredential();
DataLakeServiceClient serviceClient = new DataLakeServiceClient(new Uri(storageUri), cred);
DataLakeFileSystemClient fileSystem = serviceClient.CreateFileSystem("test");
}

如何创建文件共享目录而不是blob容器?我已经尝试使用xxxxxxx.file.core.windows.net而不是dfs,但得到一个错误AuthenticationErrorDetail: Authentication scheme Bearer is not supported for Files.

这个来自Azure Storage Eplorer的剪辑展示了我的意思。

存储资源管理器snip

我需要使用不同的API吗?不同的授权?感谢您的帮助。

这个示例可以满足我的需要。

static void Main(string[] args)
{
string storageUri = "https://xxxxxx.file.core.windows.net/myshare";
string sas = "SAS credential to file share xxxxxx.file.core.windows.net/myshare. SAS must include create privilege.";
AzureSasCredential cred = new AzureSasCredential(sas);
ShareClient shareClient = new ShareClient(new Uri(storageUri), cred);
Response<ShareDirectoryClient> resp = shareClient.CreateDirectory("test");
}

最新更新