question

NoahVanLoen avatar image
0 Votes"
NoahVanLoen asked Sumarigo-MSFT edited

Azure Logic App - Overwrite Blob

When using "Create Blob" to write a blob from Logic App to Blob storage v2, I get the following error when there's an existing file in that location.

 {
   "status": 409,
   "message": "Another active upload session exists, please retry after some time.\r\nclientRequestId: 4778f0b6-25b8-4321-a1f7-d7a7a7925461",
   "error": {
     "message": "Another active upload session exists, please retry after some time."
   },
   "source": "azureblob-wus.azconn-wus-01.p.azurewebsites.net"
 }

When looking at blob properties, the file has a Lock on the Lease. How can I a) clear the Lock so the operation completes, or b) force an overwrite?

25702-image.png


azure-logic-appsazure-blob-storageazure-data-lake-storage
image.png (6.2 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Sumarigo-MSFT avatar image
0 Votes"
Sumarigo-MSFT answered Sumarigo-MSFT edited

@NoahVanLoen & @RaviPalihena-7846 @StevenTchir-9477 Operations you mentioned "delete/create" with the lease control can be achieved via Blob Service REST API and HTTP action. Before deleting blob, the lease should be established via lease container. The request header should contain headers: 'x-ms-lease-action: acquire' and 'x-ms-lease-duration: <value in seconds>'. The service will respond with a response code and unique lease ID 'x-ms-lease-id'. While the lease is active, You must include the lease ID with any request to delete the container or to renew, change, or release the lease.

Delete blob could contain a large number of snapshots and the operation could time out. If that happens, the client should retry the request, please refer to https://docs.microsoft.com/en-us/rest/api/storageservices/delete-blob#remarks

For releasing the established lease, request header should contain: 'x-ms-lease-id: <lease id>' and 'x-ms-lease-action: release'.

Archiving blob, for now, could be achieved in the following way: create a new blob container with the new name and copy blobs from the old blob container to the new one. Once the blobs are copied, you can delete the old blob container.

If you would like to have a fully-automated process in the connector, please vote on the user voice forum. We tend to pick the top ones every time we do the planning: https://feedback.azure.com/forums/287593-logic-apps?category_id=145803


Hope this helps!

Kindly let us know if the above helps or you need further assistance on this issue.



Please don’t forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Sumarigo-MSFT avatar image
0 Votes"
Sumarigo-MSFT answered NoahVanLoen commented

@NoahVanLoen You can use Azure Storage Explorer to break the lease, navigate to your Storage account you want to break the lease-->File right click and there you will see an option to "Bread Lease" option.

25763-capture.jpg


The Lease Blob operation creates and manages a lock on a blob for write and delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. In versions prior to 2012-02-12, the lock duration is 60 seconds.

For more information refer here for Lease Blob

Additional information: Blob Service error codes and Microsoft TechNet Article show how to break a locked lease of blob storage
Break lease using PowerShell

Hope this helps!

Kindly let us know if the above helps or you need further assistance on this issue.


Please don’t forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.



capture.jpg (54.5 KiB)
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks @Sumarigo-MSFT - I found that operation in the Storage Explorer, and it works as you describe. However, as @StevenTchir-9477 and @RaviPalihena-7846 mention, I'm looking for a way to handle this programmatically from within Logic app. There are 2 paths I'm thinking about now:
1) Perform a "Create Blob" operation with an "Override Lock" flag (if such a thing exists), or
2) Move the existing blob to another location (ex: Archive) (or rename existing blob in same location) and then "Create Blob"

Thoughts on how this may be accomplished?

0 Votes 0 ·

Hi @Sumarigo-MSFT - any further guidance on this? I've read through the https://docs.microsoft.com/en-us/rest/api/storageservices/lease-blob documentation, and see that I can send an API call to break the lease (which I can do even if I don't have the lease id) or release the lease (which requires a lease id).

I would expect that the lease to be temporary in nature, but see your note above that the lock duration can vary. What is the default?
Is there a way to specify lock duration during Create Blob operation (or perhaps at the storagev2 level)?

If not, perhaps the best way to do this is to send a Lease Blob REST API call right after Create Blob, using the lease id provided, to either release or break the lease? I suppose I could also specify/change the lease duration on the blob this way using x-ms-lease-break-period?

0 Votes 0 ·

One other pattern I've noted - on blobs that I've created that had a Lease Status = Locked, they are also missing the Content-MD5 value. For those that have a Content-MD5 value, the Lease Status is Unlocked. Coincidence or causative?

0 Votes 0 ·
StevenTchir-9477 avatar image
0 Votes"
StevenTchir-9477 answered RaviPalihena-7846 commented

The above works, but is only a short-term solution. How can this be handled using Logic Apps for a fully-automated process? In my case, when using a blob storage write action for data lake gen2, an infinite lock is being placed on every written file.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Did you manage to find a solution to this. ?
I have the same issue and have no information on how to control the lease and lock from the logic app

0 Votes 0 ·
NoahVanLoen avatar image
0 Votes"
NoahVanLoen answered

Hi @Sumarigo-MSFT - one last ping on this topic; please see my comment above https://docs.microsoft.com/answers/comments/105352/view.html

What I've done in the interim is to Delete the Blob before I Create the new one. Seems to work just using the blob name, even though the Create fails if the blob is still there. Still not understanding why some blobs get created with an infinite lease, and others do not...

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Sumarigo-MSFT avatar image
1 Vote"
Sumarigo-MSFT answered

@NoahVanLoen & @RaviPalihena-7846 @StevenTchir-9477 Firstly, apologies for the delay in responding here and any inconvenience this issue may have caused.

Could you provide the following information where you experienced the issue?
Region
Resource ID
Run ID(s)
Timeframe in UTC

I wish to engage with you offline for a closer look and provide a quick and specialized assistance, please send an email with subject line “Attn:subm” to AzCommunity@Microsoft.com referencing this thread and the Azure subscription ID, I will follow-up with you.
Thanks for your patience and co-operation.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.