程序问答   发布时间:2022-06-02  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了通过 Azure Functions 中的 C# 将文件从一个 DataLake Gen2 复制到另一个 Data Lake Gen2大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

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

开发过程中遇到通过 Azure Functions 中的 C# 将文件从一个 DataLake Gen2 复制到另一个 Data Lake Gen2的问题如何解决?下面主要结合日常开发的经验,给出你关于通过 Azure Functions 中的 C# 将文件从一个 DataLake Gen2 复制到另一个 Data Lake Gen2的解决方法建议,希望对你解决通过 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

大佬总结

以上是大佬教程为你收集整理的通过 Azure Functions 中的 C# 将文件从一个 DataLake Gen2 复制到另一个 Data Lake Gen2全部内容,希望文章能够帮你解决通过 Azure Functions 中的 C# 将文件从一个 DataLake Gen2 复制到另一个 Data Lake Gen2所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。