[英]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.