409 Conflict cloud protocol_error ai_generated true

409 Conflict: The lease ID specified did not match the lease ID of the blob snapshot

ID: cloud/azure-blob-storage-lease-conflict-on-snapshot

Also available as: JSON · Markdown · 中文
85%Fix Rate
87%Confidence
1Evidence
2023-09-22First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
Azure Storage REST API: 2019-07-07 active
Azure SDK for .NET: >= 12.10.0 active
Azure Portal: latest active

Root Cause

When attempting to delete or modify a blob that has an active lease, the operation fails if the lease ID is not provided correctly, especially when the blob has snapshots that inherit or require separate lease management.

generic

中文

当尝试删除或修改具有活动租约的 Blob 时,如果未正确提供租约 ID,操作将失败,尤其是当 Blob 具有继承或需要单独租约管理的快照时。

Official Documentation

https://learn.microsoft.com/en-us/rest/api/storageservices/lease-blob#status-codes

Workarounds

  1. 90% success Retrieve the current lease ID by calling 'Get Blob Properties' and then use that lease ID in the delete request. Example in Azure CLI: 'az storage blob lease break --account-name <storage-account> --container-name <container> --blob-name <blob> --lease-duration -1' then delete with 'az storage blob delete --account-name <storage-account> --container-name <container> --name <blob> --lease-id <lease-id>'.
    Retrieve the current lease ID by calling 'Get Blob Properties' and then use that lease ID in the delete request. Example in Azure CLI: 'az storage blob lease break --account-name <storage-account> --container-name <container> --blob-name <blob> --lease-duration -1' then delete with 'az storage blob delete --account-name <storage-account> --container-name <container> --name <blob> --lease-id <lease-id>'.
  2. 85% success If the blob has snapshots, delete the snapshots first with the same lease ID, then delete the base blob. Use 'az storage blob delete --account-name <storage-account> --container-name <container> --name <blob> --delete-snapshots include --lease-id <lease-id>'.
    If the blob has snapshots, delete the snapshots first with the same lease ID, then delete the base blob. Use 'az storage blob delete --account-name <storage-account> --container-name <container> --name <blob> --delete-snapshots include --lease-id <lease-id>'.

中文步骤

  1. Retrieve the current lease ID by calling 'Get Blob Properties' and then use that lease ID in the delete request. Example in Azure CLI: 'az storage blob lease break --account-name <storage-account> --container-name <container> --blob-name <blob> --lease-duration -1' then delete with 'az storage blob delete --account-name <storage-account> --container-name <container> --name <blob> --lease-id <lease-id>'.
  2. If the blob has snapshots, delete the snapshots first with the same lease ID, then delete the base blob. Use 'az storage blob delete --account-name <storage-account> --container-name <container> --name <blob> --delete-snapshots include --lease-id <lease-id>'.

Dead Ends

Common approaches that don't work:

  1. 70% fail

    If the lease is still active, the delete operation fails with a 409 error; the lease must be explicitly released or renewed.

  2. 90% fail

    The Azure Storage API requires an exact lease ID match; wildcards are not supported.

  3. 60% fail

    Snapshots may have their own leases or inherit the base blob's lease; deleting them without the correct lease ID can also fail.