Get the last Child Item in Get metadata activity

Billapati, Naveen 41 Reputation points
2021-09-22T08:16:20.107+00:00

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 Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,321 questions
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
9,643 questions
0 comments No comments
{count} votes

Accepted answer
  1. Saurabh Sharma 23,751 Reputation points Microsoft Employee
    2021-09-22T21:26:36.4+00:00

    Hi @Billapati, Naveen ,

    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.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful