简体   繁体   English

尝试将文件从 Azure Data Lake 文件夹移动到另一个

[英]Trying to move a file from a Azure Data Lake folder to another

I have function app read the file from data lake and do some processing of the file content.我有功能应用程序从数据湖读取文件并对文件内容进行一些处理。 If it failed it move the file to the "Error" folder.如果失败,则将文件移动到“错误”文件夹。 I tried this but was unsuccessful.我试过这个但没有成功。 Solution I tried SO-solution解决方案我试过SO-solution

public static async Task<DataLakeFileClient> MoveDirectory(string file)
{        
    DataLakeServiceClient serviceClient = await GetDataLakeClient(); 

    DataLakeFileSystemClient filesystemClient = 
    serviceClient.GetFileSystemClient(<CONTAINER>);
    
    DataLakeFileClient fileClient = 
    filesystemClient.GetFileClient("Provision/" + file);
    
    return await fileClient.RenameAsync("Provision/Error/" + file);
}

Cause a 404 SourcePathNotFound.导致 404 SourcePathNotFound。

Any tips or advice how I can move files from one directory to another?任何提示或建议如何将文件从一个目录移动到另一个目录?

After making a few changes we could able to get this work.进行一些更改后,我们可以完成这项工作。 While using GetFileClient for the required file you need to use DataLakeFileSystemClient instead of DataLakeServiceClient.在为所需文件使用 GetFileClient 时,您需要使用 DataLakeFileSystemClient 而不是 DataLakeServiceClient。 Below is the code that worked for me.下面是对我有用的代码。

DataLakeServiceClient dataLakeServiceClient = new DataLakeServiceClient("<CONNECTION STRING>");
DataLakeFileSystemClient dataLakeFileSystemClient = dataLakeServiceClient.GetFileSystemClient("<CONTAINER>");

DataLakeFileClient sourceDataLakeFileClient = dataLakeFileSystemClient.GetFileClient("provision/<FILENAME>");
return await sourceDataLakeFileClient.RenameAsync("provision/Error/<FILENAME>");

RESULTS:结果:

Before execution执行前

在此处输入图像描述

After execution执行后

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Azure Data Lake Gen2 - 如何使用 C# 将文件从文件夹移动到另一个文件夹 - Azure Data Lake Gen2 - How do I move files from folder to another folder using C# 尝试从Azure Data Lake删除文件时引发异常 - Exception raised while trying to delete file from Azure Data Lake 尝试从Data Lake存储中打开文件时抛出Microsoft.Rest.Azure.CloudException - Microsoft.Rest.Azure.CloudException was thrown when trying to open file from Data Lake store 通过 Azure 函数中的 C# 将文件从一个 DataLake Gen2 复制到另一个 Data Lake Gen 2 - Copy file from one DataLake Gen2 to another Data Lake Gen 2 via C# in Azure Functions 如何使用 Azure 存储 SDK 将 Azure 文件存储上的文件从一个子文件夹移动到另一个子文件夹? - How to move a file on Azure File Storage from one sub folder to another sub folder using the Azure Storage SDK? 在 Data Lake Gen 2 中将文件从一个容器复制到另一个容器 - Copy file from one container to another container in Data Lake Gen 2 在Azure Data Lake中解压缩.gz文件 - Decompress .gz file in Azure Data lake 从Azure Data Lake下载文件 - Download files from the azure data lake Azure Data Lake存储通过C#脚本创建文件夹 - Azure Data Lake store create folder via C# script 尝试使用子文件夹C#将文件从一个文件夹移动到另一个文件夹 - Trying to move files from one folder to another with subfolders C#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM