Skip to content

Instantly share code, notes, and snippets.

@woeterman94
Created February 22, 2022 13:51
Show Gist options
  • Save woeterman94/afb34e9560061c7d09c286cce556f43a to your computer and use it in GitHub Desktop.
Save woeterman94/afb34e9560061c7d09c286cce556f43a to your computer and use it in GitHub Desktop.
Logic app: Copy file to another folder in FTP
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"For_each_3": {
"actions": {
"Condition": {
"actions": {
"Copy_file": {
"inputs": {
"headers": {
"ReadFileMetadataFromServer": true
},
"host": {
"connection": {
"name": "@parameters('$connections')['ftp_1']['connectionId']"
}
},
"method": "post",
"path": "/datasets/default/copyFile",
"queries": {
"destination": "/content/random/@{items('For_each_3')?['DisplayName']}",
"overwrite": true,
"queryParametersSingleEncoded": true,
"source": "@items('For_each_3')?['Path']"
}
},
"operationOptions": "DisableAsyncPattern",
"runAfter": {},
"type": "ApiConnection"
},
"Delay": {
"inputs": {
"interval": {
"count": 10,
"unit": "Second"
}
},
"runAfter": {
"Copy_file": [
"Succeeded"
]
},
"type": "Wait"
},
"Delete_file": {
"inputs": {
"headers": {
"SkipDeleteIfFileNotFoundOnServer": false
},
"host": {
"connection": {
"name": "@parameters('$connections')['ftp_1']['connectionId']"
}
},
"method": "delete",
"path": "/datasets/default/files/@{encodeURIComponent(encodeURIComponent(items('For_each_3')?['Path']))}"
},
"runAfter": {
"Increment_variable": [
"Succeeded"
]
},
"type": "ApiConnection"
},
"Increment_variable": {
"inputs": {
"name": "Amount",
"value": 1
},
"runAfter": {
"Delay": [
"Succeeded"
]
},
"type": "IncrementVariable"
}
},
"expression": {
"and": [
{
"less": [
"@variables('Amount')",
10
]
}
]
},
"runAfter": {},
"type": "If"
}
},
"foreach": "@body('List_files_in_folder')",
"runAfter": {
"List_files_in_folder": [
"Succeeded"
]
},
"runtimeConfiguration": {
"concurrency": {
"repetitions": 1
}
},
"type": "Foreach"
},
"Initialize_variable": {
"inputs": {
"variables": [
{
"name": "Amount",
"type": "integer",
"value": 0
}
]
},
"runAfter": {},
"type": "InitializeVariable"
},
"List_files_in_folder": {
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['ftp_1']['connectionId']"
}
},
"method": "get",
"path": "/datasets/default/folders/@{encodeURIComponent(encodeURIComponent('L3VucmVsZWFzZWQvcmFuZG9t'))}"
},
"metadata": {
"L3VucmVsZWFzZWQvcmFuZG9t": "/unreleased/random"
},
"runAfter": {
"Initialize_variable": [
"Succeeded"
]
},
"type": "ApiConnection"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {
"$connections": {
"defaultValue": {},
"type": "Object"
}
},
"triggers": {
"Recurrence": {
"evaluatedRecurrence": {
"frequency": "Week",
"interval": 1,
"schedule": {
"weekDays": [
"Friday"
]
}
},
"recurrence": {
"frequency": "Week",
"interval": 1,
"schedule": {
"weekDays": [
"Friday"
]
}
},
"type": "Recurrence"
}
}
},
"parameters": {
"$connections": {
"value": {
"ftp_1": {
"connectionId": "redacted../providers/Microsoft.Web/connections/ftp-1",
"connectionName": "ftp-1",
"id": "redacted"
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment