通过 Azure Functions 中的 C# 将文件从一个 DataLake Gen2 复制到另一个 Data Lake Gen2

问题描述

我想做一些简单的事情!!!

通过 Azure 函数中的 c# 代码将 blob 从位于 dataLake gen 2 (SourceContainer) 中的容器 (SourceDataLake) 复制到第二个 DatLake (TargetDataLake)。

我的 Azure Function 和 SourceDataLake间的连接通过专用链接和专用端点进行保护。

DataLakeDirectoryClient sourcedirectoryClient2 = sourceDataLakeFileSystemClient.GetDirectoryClient(myPath);
DataLakeFileClient sourcefileClient = sourcedirectoryClient2.GetFileClient(myBlobName);
Response<FileDownloadInfo> downloadResponse = await sourcefileClient.ReadAsync(); //I get the error in this line
Stream reader = downloadResponse.Value.Content;

DataLakeDirectoryClient targetdirectoryClient = taregetDataLakeFileSystemClient.GetDirectoryClient(TargetDirectory);
DataLakeFileClient targetfileClient = await targetdirectoryClient.CreateFileAsync(myBlobName);

await targetfileClient.UploadAsync(reader,true);

对于 DataLake 的身份验证,我使用此功能

public static DataLakeFileSystemClient GetDataLakeFileSystemClient(string containerName,string dataLakeName,string dataLakeAccessKey)
{
    StorageSharedKeyCredential storageSharedKeyCredential = new StorageSharedKeyCredential(dataLakeName,dataLakeAccessKey);

    DataLakeClientOptions options = new DataLakeClientOptions(DataLakeClientOptions.ServiceVersion.V2019_07_07);
    DataLakeServiceClient dataLakeServiceClient = new DataLakeServiceClient(
        new Uri(string.Concat("https://",dataLakeName,".dfs.core.windows.net")),storageSharedKeyCredential,options);

    DataLakeFileSystemClient dataLakeFileSystemClient = dataLakeServiceClient.GetFileSystemClient(containerName);
    return dataLakeFileSystemClient;
}

代码对我不起作用。如果我从 SourceDataLake删除 Priavet Link Private Endpoint,则它可以工作。不知何故私有链接和私有端点不适用于这行代码

Response<FileDownloadInfo> downloadResponse = await sourcefileClient.ReadAsync();

你知道我该如何解决这个问题吗?或者有什么更好的方法可以从 DataLake gen2 复制 blob?

解决方法

抱歉,我无法解决当前的问题,但是当您询问其他选项时,我认为您可以探索 Azure 数据工厂。 https://docs.microsoft.com/en-us/azure/data-factory/connector-azure-data-lake-storage

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...