0
votes

I am trying to delete a file from Azure ADLS storage through Talend. Upon my checking, I couldn't find any option to connect to ADLS from Talend and delete a file or folder. As another option, I am trying to run a cURL command from Talend shell to delete using the ADLS API.

**

  • ADLS Gen2 API reference

**: https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/delete

I have created a SAS token from the Storage account.

My cURL command looks like below.

curl -X DELETE -H "x-ms-date: Thu, 28 May 2020 05:51:37 GMT" https://account10.dfs.core.windows.net/testfolder/test1/test2/?<SAS Token>

I am trying to delete the files inside test2 folder.

When running, I am getting the below error.

{"error":{"code":"InvalidUri","message":"The request URI is invalid..

Can anyone help on the same.

Thanks Sathya

1
I noticed that you have a trailing slash (/) in your path. Can you try by removing that? Try something like https://account10.dfs.core.windows.net/testfolder/test1/test2?<SAS Token>.Gaurav Mantri

1 Answers

1
votes

Update: a sample command to delete non-empty directory(Note: in this sample, replace the ? with & just before the sasToekn):

curl -X DELETE -H "x-ms-date: Thu, 28 May 2020 05:51:37 GMT" "https://account10.dfs.core.windows.net/testfolder/test1/test2?recursive=true&sv=2019-10-10&ss=bfqt&srt=sco&sp=rwdlacupx&se=2020-05-29T08:50:28Z&st=2020-05-29T00:50:28Z&spr=https&sig=xxx"

Test result:

enter image description here


As Mantri mentioned in the comment, there is a redundant '/' after test2 in the url. You should remove it.

Besides that, you should note the following 2 considerations:

1.If you want to delete a non-empty folder, you should add recursive=true in the url. The curl command like below:

curl -X DELETE -H "x-ms-date: Thu, 28 May 2020 05:51:37 GMT" "https://account10.dfs.core.windows.net/testfolder/test1/test2?recursive=true&sasToken"

2.If you want to delete a file, use the command like below:

curl -X DELETE -H "x-ms-date: Thu, 28 May 2020 05:51:37 GMT" "https://account10.dfs.core.windows.net/testfolder/test1/test2/aa.txt?sasToken"