Hello amerm,
Welcome to the Microsoft Q&A and thank you for posting your questions here.
I understand that you would like to create a workflow that would check each file's last modified where I want it to move files and folders that are older than 120 days to a different storage account.
Your Logic App workflow should be similar to the followings:
1. Trigger: Recurrence
2. Action: Initialize Variables
3. Action: List Files in Folder
4. Control: For Each (loop through files)
- Action: Get File Metadata
- Condition: If file is older than 120 days
- True:
- Copy File
- Delete File
- Append File Path to Variable
5. Action: Create File (Report)
6. Optional: Recursive Call for Nested Folders
Regarding your questions:
- how to list each azure file in the in the storage account?
To list files and folders in an Azure File Storage, you can use the Azure File Storage connector in Logic Apps. Here’s how you can set it up:
- Create a Logic App in the Azure portal.
- Add a new step and search for the Azure File Storage connector.
- Choose the "List files in folder" action**. You will need to provide the path to the folder you want to list.
- How to loop between each azure file and its contents to get files and folders that are older than 120 days?
To loop through each file and folder, you can use the "For each" control in Logic Apps:
- After listing the files, add a "For each" control.
- Set the output of the "List files in folder" action as the input for the "For each" control.
- Inside the "For each" loop, you can add actions to get the metadata of each file, such as the last modified date.
To check the last modified date and move files older than 120 days:
- Inside the "For each" loop, add a condition to check if the file's last modified date is older than 120 days.
- If the condition is true, add an action to move the file to a different storage account. You can use the "Copy file" and "Delete file" actions to achieve this.
- How do I list the results retaining each file/folder's path in a text file for example to have like local report stored somewhere?
To list the results and retain each file/folder's path:
- Inside the "For each" loop, add an action to append the file path to a variable.
- After the loop, add an action to create a file in a storage account or send an email with the list of file paths.
- what I would do if I needed to limit the scope of this to a certain folder in an Azure file?
To limit the scope to a certain folder, you can specify the folder path in the "List files in folder" action. This way, the Logic App will only process files and folders within the specified path.
I hope this is helpful! Do not hesitate to let me know if you have any other questions.
Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful.