@Keshav Rajput Thanks for reaching out. Unfortunately, we don't have any built-in Azure file storage connector triggers to copy files from one location to another location. To achieve this, you need to create a custom workflow by combining multiple actions (compose, list files, get file, control, copy file). I have created a workflow by including all the actions that i have mentioned before.
- Used recurrence as trigger to run the workflow at a frequency for every minute.
- Using
Get FilesPulled the list of existing files in that file share. - Added
for eachloop to iterate those lists of files usingGet File metadata using pathto get the file creation time. - Added the below condition to check the existing file is latest or not, if the condition is true, it will copy the file from source location to destination location.
div(sub(ticks(utcNow()),ticks(body('Get_file_metadata_using_path')?['LastModified'])),3600000000)
**workflow. Json file: **
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"For_each": {
"actions": {
"Condition": {
"actions": {
"Copy_file": {
"inputs": {
"headers": {
"ReadFileMetadataFromServer": true
},
"host": {
"connection": {
"name": "@parameters('$connections')['azurefile']['connectionId']"
}
},
"method": "post",
"path": "/datasets/default/copyFile",
"queries": {
"destination": "<destinationPath>",
"overwrite": true,
"queryParametersSingleEncoded": true,
"source": "@items('For_each')?['Path']"
}
},
"runAfter": {},
"type": "ApiConnection"
}
},
"expression": {
"and": [
{
"equals": [
"@div(sub(ticks(utcNow()),ticks(body('Get_file_metadata_using_path')?['LastModified'])),3600000000)",
0
]
}
]
},
"runAfter": {
"Get_file_metadata_using_path": [
"Succeeded"
]
},
"type": "If"
},
"Get_file_metadata_using_path": {
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['azurefile']['connectionId']"
}
},
"method": "get",
"path": "/datasets/default/GetFileByPath",
"queries": {
"path": "@items('For_each')?['Path']",
"queryParametersSingleEncoded": true
}
},
"runAfter": {},
"type": "ApiConnection"
}
},
"foreach": "@body('List_files')?['value']",
"runAfter": {
"List_files": [
"Succeeded"
]
},
"type": "Foreach"
},
"List_files": {
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['azurefile']['connectionId']"
}
},
"method": "get",
"path": "/datasets/default/foldersV2/@{encodeURIComponent(encodeURIComponent('JTJmdGVzdGluZ2ZpbGVz'))}",
"queries": {
"nextPageMarker": "",
"useFlatListing": false
}
},
"metadata": {
"JTJmdGVzdGluZ2ZpbGVz": "/testingfiles"
},
"runAfter": {},
"type": "ApiConnection"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {
"$connections": {
"defaultValue": {},
"type": "Object"
}
},
"triggers": {
"Recurrence": {
"evaluatedRecurrence": {
"frequency": "Minute",
"interval": 1
},
"recurrence": {
"frequency": "Minute",
"interval": 1
},
"type": "Recurrence"
}
}
},
"parameters": {
"$connections": {
"value": {
"azurefile": {
"connectionId": "/subscriptions/<subscriptionId>/resourceGroups/<resourcegroup>/providers/Microsoft.Web/connections/azurefile",
"connectionName": "azurefile",
"id": "/subscriptions/<subscriptionId>/providers/Microsoft.Web/locations/eastus/managedApis/azurefile"
}
}
}
}
}
**Here is the screenshot of the Workflow Designer: **
Feel free to reach back to me if you have any further questions.