【问题标题】:Azure ADLS Gen 2 writing to blob storageAzure ADLS Gen 2 写入 blob 存储
【发布时间】:2019-02-06 02:31:37
【问题描述】:

我很难使用 c# 写入 ADLS Gen 2 blob 存储。 有这个功能吗?

我正在尝试将我的代码从 ADLS Gen 1 更新到 Gen 1。

这段代码适用于 ADLS Gen 1

public static async Task<HttpResponseMessage> Run
                (   [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)]HttpRequestMessage req,
                    Binder binder , 
                    TraceWriter log)

    {
var container = "my_container";
var path = container + "/test.txt" ;
using (var writer = await binder.BindAsync<TextWriter>(new BlobAttribute(path)))
{
    writer.Write("Hello there !!!!!");
}
}

【问题讨论】:

标签: azure-storage azure-data-lake


【解决方案1】:

截至 2019 年 2 月,目前没有可用于在 Data Lake Gen 2 中写入文件的 .NET SDK,因此您的代码将无法运行。

检查以下documentation

没有可用于 Data Lake Storage Gen2 帐户的 SDK。

有关最新的 SDK 可用性,请参见此处的“编程接口”图表:https://docs.microsoft.com/en-gb/azure/storage/blobs/data-lake-storage-upgrade?toc=%2fazure%2fstorage%2fblobs%2ftoc.json


在这个阶段,您唯一的选择是使用 REST API。可用文档here

【讨论】:

    【解决方案2】:

    您还可以以编程方式调用 AzCopy v10,传递 --output-type=json 标志以使其输出可由您的 C# 代码解析。如果您正在从磁盘上传/下载到磁盘,这就是有效的,这就是 Storage Explorer 所做的。但是,如果您要从磁盘上不存在的内存“文件”上传/下载到内存中的“文件”,则需要使用 @mai 提到的 REST。

    【讨论】:

      【解决方案3】:

      我认为您可能想要利用最近发布的(预览版)csharp SDK 版本,此处记录了该版本:https://docs.microsoft.com/en-us/azure/storage/blobs/data-lake-storage-directory-file-acl-dotnet

      【讨论】:

        猜你喜欢
        • 2020-11-20
        • 1970-01-01
        • 1970-01-01
        • 2021-04-30
        • 2019-03-08
        • 2023-01-03
        • 1970-01-01
        • 2020-08-29
        • 2019-09-23
        相关资源
        最近更新 更多