Kerem
Kerem

Reputation: 1553

Logic Apps creates a file for each copied folder with the same name

I have an Azure environment with Logic Apps and a storage account. My pipeline moves data from SharePoint to the storage account with a "When a file is created or modified (properties only)" trigger.

Every time my pipeline copies a folder, it also creates a file with the same name in the storage account: File and folder with the same name

Here is my Logic Apps pipeline:

  1. When a file is created or modified (properties only)
  2. Get file content using path (Folder path + file name with extension)
  3. Check whether blob exists
  4. Delete blob
  5. Upload blob to storage container

How can I prevent those files being created per each copied folder?

Upvotes: 0

Views: 795

Answers (1)

SwethaKandikonda
SwethaKandikonda

Reputation: 8244

  • If you are following the same flow as mentioned, the flow will fail at Get file content using path (Folder path + file name with extension) step itself, since SharePoint could differentiate between file and folder.

  • Create Block Blob Step will be creating additional empty files as because Blob Storage will not consider folders or files as 2 different things.

  • It takes both file and folder as blob. So, when you are trying to create a blob inside storage account (which is probably a folder) it will create an additional empty file for folder too.

  • After reproducing from my end, to reproduce the same results as yours, I have enabled the Configure run after for Create Block Blob Step.

enter image description here

enter image description here

Hierarchy in Storage Account:

enter image description here

Alternatively, if there is no 'Configure run after' in your flow, you can add trigger condition to your logic app trigger. Consider you have folders in SharePoint as below.

folder1/f2/f3/sample.txt

With the same flow the logic app will be triggering 4 times.

enter image description here

To avoid such mishaps, you need to mention the below trigger condition in your trigger.

@equals(triggerBody()?['{IsFolder}'], false)

enter image description here

Results:

enter image description here

Upvotes: 1

Related Questions