Azure Datalake Gen2 Rename File Issue

See original GitHub issue
  • azure.storage.filedatalake:
  • **12.0.0.b **:
  • Windows:
  • 3.73:

Describe the bug When trying to get azure.storage.filedatalake rename_file method working for an existing file_client I receive the following error: file_client.rename_file(file_client.file_system_name+'/'+target_path) azure.core.exceptions.ResourceNotFoundError: Operation returned an invalid status 'The parent directory of the destination path does not exist.' ErrorCode:RenameDestinationParentPathNotFound error:{'code': 'RenameDestinationParentPathNotFound', 'message': 'The parent directory of the destination path does not exist.\nRequestId:889d285a-601f-001d-3afc-d9ef4b000000\nTime:2020-02-02T19:11:34.7429024Z'}

Provided is my code snippet: -Creating a file_client for an existing file -Creating target path name by taking the file_system name and appending it to the full path of the new file

logger.info("Now loading file: {0} into it's corresponding raw directory: {1}".format(filename, curated_path)) file_client = self.datalake_conn.file_system.get_file_client(filename) target_path = self.datalake_conn.file_system_name+'/'+curated_path+filename.split('/')[1] file_client.rename_file(target_path)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
v-xutocommented, Feb 19, 2020

Hi @markpearl , Here are the steps on how to use rename_file, your question appears in step3.: Step 1, create a DataLakeServiceClient Object.
Step 2, get file client.
step 3, create target path. step 4, rename file.

The detailed code is shown below for how to use rename_file (here is the official sample ):

from azure.storage.filedatalake import DataLakeServiceClient 
account_name = 'AccountName' 
account_key = 'AccountKey' 
# Step 1, create a DataLakeServiceClient Object. 
dsc = DataLakeServiceClient(account_url="{}://{}.dfs.core.windows.net".format( 
       "https", 
       account_name 
   ), credential=account_key) 
# step 2, get file client.  
file_client=dsc.get_file_client(file_system='FileSystem', file_path='FolderName/YourFileName') 
# step 3, create target path. 
target_path=file_client.file_system_name + '/' + file_client.path_name.split('/')[0]+"/"+"NewFileName" 
# step 4, rename file. 
new_file_client = file_client.rename_file(target_path) 

@jongio

0reactions
xiafu-msftcommented, Jun 15, 2020

close this issue for now, feel free to reopen it if you have any question

Read more comments on GitHub >

github_iconTop Results From Across the Web

Azure Function apps Function to rename file in Azure Data ...
I have few text files under Azure Data lake Storage Gen 2 raw container, I want to rename these file like strip some...
Read more >
Problem when rename file in Azure Databricks from a data lake
On the other hand, I have tried to rename the file with pySpark, but it uses a hadoop library (org.apache.hadoop.conf.Configuration) that I do ......
Read more >
Rename Files in Data Lake Using Azure Databricks - YouTube
Created By: Muditha Pelpola LinkedIn: https://www.linkedin.com/in/muditha-pelpola # Azure #AzureDatalake #Databricks #python #dataengineering ...
Read more >
Azure Data Factory rename files with copy | Medium - Tech Zero
Azure Data Lake Storage Gen2 > DelimitedText > Linked Service to Connect to ADLSG2. In my storage account, I have kept the two...
Read more >
Hadoop Azure Support: ABFS — Azure Data Lake Storage Gen2
Presents a hierarchical file system view by implementing the standard Hadoop FileSystem interface. Supports configuration of multiple Azure Blob ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found