Azure ADLS Gen 2写入Blob存储

时间:2019-02-06 02:31:37

标签: azure-storage azure-data-lake

我很难用c#编写ADLS Gen 2 Blob存储。 可以使用此功能吗?

我正在尝试将代码从ADLS第1代更新为第1代。

这段代码与ADLS第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 !!!!!");
}
}

3 个答案:

答案 0 :(得分:1)

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

检查以下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

答案 1 :(得分:0)

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

答案 2 :(得分:0)

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

相关问题