question

BillapatiNaveen-2631 avatar image
0 Votes"
BillapatiNaveen-2631 asked SaurabhSharma-msft commented

Get the last Child Item in Get metadata activity

Hello Everybody,

I have a container with a blob called Weekly. Each week a new subfolder is added to the weekly blob and each each day a new csv file is added to the respective week subfolder. I am trying to use schedule trigger every sunday. Once the pipeline is triggered I need to get the latest week subfolder in the blob. I am thinking of following solutions.

  1. I have around 200 week subfolder. Using get metadata activity and for each loop and comparing it with latest modified date is taking too much time. Instead I am trying use get metadata activity and get the last child item and assign it to a variable called folderpath. How to do this?

  2. Using python functions how to get the latest subfolder in a blob?

Any help would be highly appreciated.

Thanks in advance
Reddy

134158-child-items.png134234-get-the-last-child-item.png134235-2nd-way.png


azure-data-factoryazure-functions
child-items.png (12.6 KiB)
2nd-way.png (13.8 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

SaurabhSharma-msft avatar image
1 Vote"
SaurabhSharma-msft answered SaurabhSharma-msft commented

Hi @billapatinaveen-2631,

Thanks for using Microsoft Q&A !!
You can extract the folder names using Lookup and Filter activity (to filter only Folders) and then you can get the last folder item from retrieved folder list with code like below -

@activity('Filter Folders').output.Value[sub(int(activity('Filter Folders').output.FilteredItemsCount),1)].Name

Here FilteredItemsCount is available through Filter activity (See screenshots below) and you could get the last item using index.
134400-image.png

Please find below the GIF which could help you understand it better.
134455-getlastfoldername.gif
Hope this would work in your scenario. Please let me know if any questions.

Thanks
Saurabh


Please do not forget to "Accept the answer" wherever the information provided helps you to help others in the community.


image.png (10.4 KiB)
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @billapatinaveen-2631,
Please let us know if you find above reply useful. If yes, please accept above as answer. This will help other community members facing similar query to refer to this solution.

Thanks
Saurabh

0 Votes 0 ·

Hi @billapatinaveen-2631,
Please let us know if you find above reply useful. If yes, please accept above as answer. This will help other community members facing similar query to refer to this solution.
In case If you already found a solution, would you please share it here with the community? Otherwise, let us know and we will continue to engage with you on the issue.

Thanks
Saurabh

0 Votes 0 ·