Azure Logic App - Overwrite Blob

Noah Van Loen 61 Reputation points
2020-09-17T20:25:18.657+00:00

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 Data Lake Storage
Azure Data Lake Storage
An Azure service that provides an enterprise-wide hyper-scale repository for big data analytic workloads and is integrated with Azure Blob Storage.
1,337 questions
Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
2,425 questions
Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
2,837 questions
0 comments No comments
{count} votes

Accepted answer
  1. Sumarigo-MSFT 43,411 Reputation points Microsoft Employee
    2020-10-12T06:30:34.677+00:00

    @Noah Van Loen & @Ravi Palihena @Steven Tchir 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://learn.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.

    0 comments No comments

5 additional answers

Sort by: Most helpful
  1. Sumarigo-MSFT 43,411 Reputation points Microsoft Employee
    2020-10-06T10:12:41.22+00:00

    @Noah Van Loen & @Ravi Palihena @Steven Tchir 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.

    1 person found this answer helpful.
    0 comments No comments

  2. Sumarigo-MSFT 43,411 Reputation points Microsoft Employee
    2020-09-18T07:51:27.817+00:00

    @Noah Van Loen 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.


  3. Steven Tchir 1 Reputation point
    2020-09-18T20:52:40.043+00:00

    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.


  4. Noah Van Loen 61 Reputation points
    2020-09-28T16:56:56.563+00:00

    Hi @Sumarigo-MSFT - one last ping on this topic; please see my comment above https://learn.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...

    0 comments No comments