I set up a LogicApp that would loop over files stored on a local system and upload them as blobs to an Azure storage account. The LogicApp was using the base component ‘Create blob (V2)’ to import the file to Azure.

When I tested this process I got the following error:

{
  "status": 409,
  "message": "Another active upload session exists, please retry after some time.\r\nclientRequestId: ",
  "error": {
    "message": "Another active upload session exists, please retry after some time."
  },
  "source": "azureblob-cus.azconn-cus-001.p.azurewebsites.net"
}

I could not find much information about the error other than the following article: Azure Logic App – Overwrite Blob

https://learn.microsoft.com/en-us/answers/questions/98579/azure-logic-app-overwrite-blob.html

Based on the article, it looks like the blobs have a lease that is held which is stopping the files from being uploaded. My first two thoughts to get around this would be:

  1. Set up a delay timer to wait as the error message instructs
  2. I was overwriting files on the Azure storage account so possibly removing those files first could resolve the issue.

Making both of these changes did not resolve the issue, I was getting the same error message when trying to create a new blob from my LogicApp. I did notice that one file was consistently importing but subsequent files were failing. This helped me find the root cause of the issue: the loop going over all of the files on the local server.

The LogicApp would loop over each file, same the filename to a local variable and run some conditional logic, then upload the file.  LogicApp for each loops default to process in parallel. This made it so the local filename variable would attempt to be set by multiple iterations of the loop and in turn this would attempt to upload blobs with the same name, to the same location, at the same time. This lines up exactly with the error message we saw.

To get around this, I went to the loop component of our LogicApp, hit Settings, and updated the Concurrency Control to ‘On’. Then we set the ‘Degree of Parallelism’ to 1. This will allow the loop to iterate over each of the files to import one at a time and remove the conflicting upload.

LogicApp for loop

Takeaways: When using for loops in LogicApps be careful about using local variables if the loop is running in parallel.

Keep reading about D365 tips and tricks here: https://markedcode.com/index.php/category/d365/

Author

Write A Comment