Azure blob snapshots not getting deleted via logic app

Viewed 326

While deleting old blobs using a logic app by giving the container path, we ran into an error message "Status code:409, "message": This operation is not permitted because the blob has snapshots”. This subsequently fails the running of the logic app. I tried to use delete blob by providing Id and Filename but the error persists. Is there any way to specifically delete blob and its corresponding snapshot using the logic app? Approaches to solving the issue are welcome. Blob's lifecycle management policy does not work for us.

1 Answers
  1. You can use an Azure Function to delete your blob including this header in your request:

x-ms-delete-snapshots: {include, only}

Required if the blob has associated snapshots. Specify one of the following two options:

  • include: Delete the base blob and all of its snapshots.
  • only: Delete only the blob's snapshots and not the blob itself.

This header should be specified only for a request against the base blob resource. If this header is specified on a request to delete an individual snapshot, the Blob service returns status code 400 (Bad Request).

If this header is not specified on the request and the blob has associated snapshots, the Blob service returns status code 409 (Conflict).

Check documentation here.

  1. You can try to filter and order your Blobs before remove your base blob, deleting snapshots first within your Logic App.
Related