How to delete blobs with block lease? - azure

Could you explain me how to delete BLOBs with blocked lease?
I have error message after try to delete:
There is currently a lease on the blob and no lease ID was specified in the request.
Property of Lease of that BLOBs objects is: Blocked

The article has a power shell script to unlock the lease of the blob files
https://msdn.microsoft.com/en-us/library/jj919145.aspx?f=255&MSPPError=-2147217396
Exract from the link
When backing up to or restoring from Windows Azure storage, SQL Server acquires an infinite lease in order to lock exclusive access to the blob. When the backup or restore process is successfully completed, the lease is released. If a backup or restore fails, the backup process attempts to clean up any invalid blob. However, if the backup fails due to prolonged or sustained network connectivity failure, the backup process may not be able gain access to the blob and the blob may remain orphaned. This means that the blob cannot be written to or deleted until the lease is released. This topic describes how to release the lease and deleting the blob

Azure Blob API support breaking the lease
https://msdn.microsoft.com/en-us/library/azure/ee691972.aspx
if you are using client library, look for those method.
or simply implement your own, below is blog post contains sample code that from Steve Marx
http://blog.smarx.com/posts/leasing-windows-azure-blobs-using-the-storage-client-library

I had this same problem and was able to delete the VHD blob through the old portal (manage.windowsazure.com).
Under the Storage blade, navigate to your storage account, click on containers, select the container, then select the VHD blob and click delete.
You will get the message stating that there is a lease on the blob, but you should also see an option to delete the disk and the blob. Select that, and it should delete the VHD blob (as well as the orphaned disk).

I just came to know that this can also be done from the Azure Storage Explorer tool(version: 0.8.13). Navigate to your .vhd file and right click where you will see 'Break Lease' option. This should do the trick.

Related

Azure Operational Backup for Azure Blobs different from soft delete?

I have enabled soft delete for blobs, containers as well as point in time restore on my storage account. If I delete my blobs, container or even the entire storage account, it can still be restored it seems. So what does the new Operational Backup for Azure Blobs actually add?
https://learn.microsoft.com/en-us/azure/backup/blob-backup-overview
https://learn.microsoft.com/en-us/azure/storage/blobs/soft-delete-blob-overview
Soft delete protection is limited than Operational back up and has to enable additional settings in
order for additional protection.
But it is useful when only individual blobs are to be protected
instead of storage account level protection.
As You can use blob soft delete only to restore an individual blob,
snapshot, directory (in a hierarchical namespace) or version. To
restore a container and its contents, container soft delete must also
be enabled for the storage account.
Operational backup is configured and managed at the storage account level, and applies to all block blobs within the storage
account and uses a backup policy and can select to store multiple
storage accounts at a time or Select containers or Selected prefix
matches to restore a subset of blobs.
It does the Continuous back up instead of x no of back ups i.e;
you don’t need to schedule any backups and is stored within the
storage account local back up.
Operational backup prevents the blobs from deleting and overwriting as it enforces delete locks on protected blobs and also backs up even if it is not deleted where as soft delete doesn’t stop from deletion but the blobs deleted can be restored and retained it till a period of time .
Data loss is less in Operational back up as Blob point-in-time restore allows restoring blob data to an earlier state. This, in turn, uses soft delete, change feed and blob versioning to retain data for the **specified duration**.
Blob soft delete The clock starts on the retention period as soon as an object is deleted or overwritten .So you can restore a soft-deleted object to its state only at the time it was deleted.
Soft delete does not afford overwrite protection for blobs in the
archive tier. Versioning is not supported for accounts that have a
hierarchical namespace.
For the blobs whose operational back up is enabled and has already soft delete enabled has its back up for extra 5 days if retention policy of op backup is less than soft delete time.Else it will remain unchanged.
Soft delete allows to undelete the blob before restore time after it is deleted or overwritten. Where as operational back up doesn’t allow deletion itself and monitoring is possible with central back up store management.
Note: Operational backup supports operations on block blobs only and
operations on containers can’t be restored. If you delete a container
from the storage account by calling the Delete Container operation,
that container can’t be restored with a restore operation. It’s
suggested you enable soft delete to enhance data protection and
recovery.
So soft delete can be used for minor protection for blob level with selective versioning changes and additional container protection where as operational backup is all together in single pack with extra protection which restores the version ,overwrites or deletion at whatever time you set it .

Managed Disks - Delete source blob?

I have a Windows VM that was built on the old "classic" model which I would like to change to the ARM model. I have used the automated methods however this doesn't give me the control I desire (the names of all the components are messy).
I have deleted the original VM leaving only the VHD in the storage account.
I have created a Managed Disk (MD) using the VHD as the source blob.
I have created a VM using the MD
When I look at the MD in the Azure portal, it still references the "Source Blob" but i'm not sure if this means the MD is still reliant on the blob and storage account or if it's just legacy/reference info.
What I need to know is, can I delete the original storage account containing the VHD now that I have a MD?
Take a backup first and then delete the backup

Azure blob storage backup

I wonder is there's an inbuilt way in azure to backup a blob account, or just a container if that can't be done. Looked into azure backup service but can't find the option for doing it, just options to backup VM.
Alternatively I can write my custom back up strategy, but not sure if it's the case that I can't find that option inbuilt.
Thanks,
There is no blob backup facility. You'll need to make your own backups (e.g. making copies of blobs, either to the same storage account or a different one). You can take snapshots, but as #Gaurav points out in comments, snapshots are tied to the original blob, so if you delete the original, you delete the snapshots.
I answered a similar question regarding backups and Table Storage, as well, here.

How can I delete a leased blob in Microsoft Azure storage

I created a virtual machine in Azure and then deleted it.
However, the associated storage account still exists.
I can't delete the storage account because it contains a container with a blob in it that has an indefinite lease.
Nothing else is using this storage account.
How can I delete this blob?
You need to delete the disk objects that are associated with the abandoned vhd's. You can do this easily in either the classic or new portal. Once you dispose of these (along with associated leases), you should be able to get rid of your storage account
In the Classic portal (manage.windowsazure.com), you just visit Virtual Machines, then Disks. Select a disk to delete, and click the trash can at the bottom of the screen.
In the new portal (portal.azure.com) you'll find the disks under OS Disks (classic) :
From there, you can select and delete the disks from the VM's you deleted.
You can Use Azure Cloud Explorer tool on Codeplex Open the Storage Account Delete all files inside that container,
Then you Can Delete the Container and the Storage Account Easily
One solution is to delete the container, whether through a GUI like a cloud explorer, tooling like Azure Storage Powershell, or using the rest API with an Azure Storage Client Library.
You don't need the blob lease to delete the container, which would also delete any blobs present in the container.

Azure Storage & Snapshots

I have a VHD in a container which was mounted by an instance (a DotNetNuke accelerator). But now the instance is stopped so the VHD is not mounted anymore.
The problem is I can't rename this VHD with any UI client. "CloudBerry Explorer for Azure Blob Storage" shows an error when I try to rename it of
This operation is not permitted because the blob has snapshots.
I tried to list snapshots in VisualStudio but it only returns the blob's name...
I tried to mount the VHD in an instance and create a file and it works!?
I'm going crazy. :)
I've managed to remove blob which has snapshots by using Microsoft Azure Storage Explorer. Steps are:
You navigate to the blob in question
Right click -> Manage Snapshots
Delete all the snapshots and the blob will disappear also
The error is accurate. If you get that, it means the blob actually has snapshots. When you mount a blob you are most likely mounting the current version and not a past snapshot. You can enumerate the snapshots using the REST API (use the 'include=snapshots option) to prove this to yourself.
If you really want to delete the blob with minimal hassle, I would suggest using https://www.myazurestorage.com (safe site from Microsoft DPE). It will enumerate your snapshots automatically and allow you to delete them. Once they are all deleted, you can also delete the blob.

Resources