title: How can I delete a lease Container with a audit log in Azure?
body: <p>There are a few questions here on Stackoverflow in this matter but all of them are when there is a lease due to Virtual Machine and its disks. The answer then is to delete the disk first to be able to delete the storage account/container.</p>
  
  <p>Example: <a href="https://stackoverflow.com/questions/10969012/how-do-i-delete-an-azure-storage-account-containing-a-leased-blob/">How do I delete an Azure storage account containing a leased blob?</a></p>
  
  <p>My problem is that I have a custom audit log that we used a leased container (We don't want anyone to manipulate logs obv.). But we moved these logs to other place so now I want to delete the old resource. But unable to due to lease lock.</p>
  
  <p>Most likely this is due to me not understanding how leases work.
  My first try was to break the lease and unlock.. This have been done:</p>
  
  <p><a href="https://i.stack.imgur.com/OOhQn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OOhQn.png" alt="enter image description here"></a></p>
  
  <p>My assumption was that I could delete the resource now but I still get the error:</p>
  
  <p>"Failed to delete 1 out of 1 container(s):
  auditlog-container: ContainerProtectedFromDeletion: The storage account stgutauditlog container auditlog-container is protected from deletion due to ImmutabilityPolicy."</p>
  
  <p>So looking at this ImmutablePolicy I tried <a href="https://docs.microsoft.com/en-us/rest/api/storagerp/blobcontainers/deleteimmutabilitypolicy" rel="nofollow noreferrer">Blob Containers - Delete Immutability Policy</a> but got the error message:</p>
  
  <pre><code>{
    "error": {
      "code": "ContainerImmutabilityPolicyFailure",
      "message": "Operation not allowed on immutability policy with incorrect etag."
    }
  }
  </code></pre>
  
  <p>Looking at eTag you are supposed to se the eTag version (only eTag related parameter) in the If-Match header. But i tried adding the eTag, tried * and others but still same message.</p>
  
  <p>Trying the <a href="https://docs.microsoft.com/en-us/rest/api/storagerp/blobcontainers/getimmutabilitypolicy" rel="nofollow noreferrer">Blob Containers - Get Immutability Policy</a> command to try and get eTag I only get the eTag allready supplied and such</p>
  
  <pre><code>{
    "id": "/subscriptions/&lt;removed&gt;/resourceGroups/&lt;removed&gt;/providers/Microsoft.Storage/storageAccounts/&lt;removed&gt;/blobServices/default/containers/auditlog-container/immutabilityPolicies/default",
    "name": "default",
    "type": "Microsoft.Storage/storageAccounts/blobServices/containers/immutabilityPolicies",
    "etag": "\"&lt;removed&gt;\"",
    "properties": {
      "immutabilityPeriodSinceCreationInDays": 8,
      "state": "Locked"
    }
  }
  </code></pre>
  
  <p>(Removed some information for security marked with removed in the code above)</p>
  
  <p>Here it says locked... But how do I remove this lock??</p>
  
  <p>Also deleting the files in it is not possible, the options are greyed out:</p>
  
  <p><a href="https://i.stack.imgur.com/sKJLx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sKJLx.png" alt="enter image description here"></a></p>
  
  <p>I don't know what step to take next or what I have missed. How do I delete this storage account/Container?</p>
  
  <p>Any help appriciated!</p>