none
Unable to delete the Storage account (Forgot to delete the Capture and deleted the VM Machine Classic)

    Question

  • Hi

    Unable to delete the Storage account (Forgot to delete the Capture and deleted the VM Machine Classic)

    How to delete the capture image and storage account now?

    Thanks

    Santosh

    Wednesday, June 22, 2016 3:07 AM

Answers

  • It is probably easier to paste the whole code into PowerShell ISE, modify it then run it.

    Or if you have issues, click Run Selection (F8) button on each selection.


    If this post was helpful, please click the up arrow or propose as answer. Nick | https://brotechcm2012.wordpress.com/

    Monday, July 4, 2016 5:25 AM

All replies

  • Do you get an error when you delete the storage account from the Azure Portal?

    Are you using Azure classic portal or Azure resource manager portal?


    If this post was helpful, please click the up arrow or propose as answer.


    Wednesday, June 22, 2016 3:15 AM
  • Hi Nick,

    I'm using Azure Portal and getting an error to ensure you delete the Image before you delete the storage account.

    Thanks

    Santosh

    Wednesday, June 22, 2016 3:19 AM
  • Hi Santosh, 

    Do you mean manage.windowsazure.com portal? Have you tried clicking on Virtual Machines, then click on Disks/Images and select the disk or image and then click delete? Then try remove the storage account.



    If this post was helpful, please click the up arrow or propose as answer.

    Wednesday, June 22, 2016 3:24 AM
  • Hi Nick,

    Deleted my Virtual machine already.

    But Storage account is still left in Resource Group.

    Thanks

    Santosh

    Wednesday, June 22, 2016 4:00 AM
  • Even though you deleted the virtual machine, the disks and image still may be left in the storage account. Have you gone to manage.windowsazure.com then clicked on Virtual Machine, and ensured nothing is left in Disks tab and Imges tab? Can you confirm you have double checked this please?

    If this post was helpful, please click the up arrow or propose as answer.

    Wednesday, June 22, 2016 4:52 AM
  • Hi Nick,

    Following error message is displayed.

    Back to progress operations

    There is currently a lease on the blob and no lease ID was specified in the request. RequestId:c3c0fe5a-0001-001a-5142-ccb3ff000000 Time:2016-06-22T04:57:04.6224297Z

    Thanks

    Santosh

    Wednesday, June 22, 2016 4:58 AM
  • Hi,

    Thank you for posting here!

    To break the locked lease of blob storage in Microsoft Azure refer below links:

    By using portal: https://blogs.technet.microsoft.com/thbrown/2015/04/04/there-is-currently-a-lease-on-the-blob-and-no-lease-id/

    By using PowerShell: https://gallery.technet.microsoft.com/How-to-break-the-locked-c2cd6492

    We also have a relatively new article that describes how to address this:

    https://azure.microsoft.com/en-us/documentation/articles/storage-cannot-delete-storage-account-container-vhd/

    Regards,

    Vikranth S.

    Wednesday, June 22, 2016 8:58 AM
    Moderator
  • Hi <g class="gr_ gr_11 gr-alert gr_spell gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="11" id="11">Vikranth</g>

    Still, I can't fix the issue.

    It couldn't find the lease ID or lease is expired message is displayed.

    Thanks

    Santosh


    Wednesday, June 29, 2016 2:26 AM
  • Hello Santosh,

    Thank you for posting your question on Microsoft TechNet.

    Microsoft Azure Storage Explorer can help you out : http://storageexplorer.com/

    Hope this information is helpful for you.

    Best Regards,

    @Jamesvandenberg
    ---------------------------------------------
    (Ps. If this information is helpful, please mark your question as answered for the community.)

    Wednesday, June 29, 2016 9:28 AM
  • Hi Santosh,

    It sounds like the VHD file has a lease on it. To delete the file, you have to first break the lease. You can do this with the following PowerShell. Put in your storage account name and key, your container name, and the name of your blob. Once you have successfully broken the lease, you should be able to delete the VHD file. If that's the only locked VHD file you have, you should be able to delete the storage account.

    #set up the storage account info
    $StorageAccountName = "YOURSTORAGEACCOUNTNAME"
    $StorageAccountKey = "YOURSTORAGEACCOUNTKEY"
    $ctx = New-AzureStorageContext -StorageAccountName $StorageAccountName -StorageAccountKey $StorageAccountKey

    $ContainerName = "YOURCONTAINERNAME"

    #get a list of blobs in the container and make sure the one you picked is there
    Get-AzureStorageBlob -Container $ContainerName -Context $ctx

    $BlobName = "YOURBLOBNAME"

    $Blob = Get-AzureStorageBlob -Context $ctx -Container $ContainerName -Blob $BlobName
    $CloudBlockBlob = [Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob] $Blob.ICloudBlob

    #check for lease
    $CloudBlockBlob.FetchAttributes()
    Write-Host "LeaseStatus = " $CloudBlockBlob.Properties.LeaseStatus `
      ", LeaseState = " $CloudBlockBlob.Properties.LeaseState `
      ", LeaseDuration = " $CloudBlockBlob.Properties.LeaseDuration


    #Break the Lease on the blob after 1 second
    $TimeSpan2 = [TimeSpan]"0:0:0:01"  #days, hours, minutes, seconds
    $CloudBlockBlob.BreakLease($TimeSpan2)
    $CloudBlockBlob.FetchAttributes()
    Write-Host "LeaseStatus = " $CloudBlockBlob.Properties.LeaseStatus `
      ", LeaseState = " $CloudBlockBlob.Properties.LeaseState `
      ", LeaseDuration = " $CloudBlockBlob.Properties.LeaseDuration

    Robin


    Sr. Content Developer at Microsoft

    Thursday, June 30, 2016 6:09 PM
  • Hi Robin,

    Thank you.

    Can I execute as a power shell script or should I execute it as an individual command?

    Thanks

    Santosh

    Monday, July 4, 2016 5:07 AM
  • It is probably easier to paste the whole code into PowerShell ISE, modify it then run it.

    Or if you have issues, click Run Selection (F8) button on each selection.


    If this post was helpful, please click the up arrow or propose as answer. Nick | https://brotechcm2012.wordpress.com/

    Monday, July 4, 2016 5:25 AM
  • Hi Santosh,

    As noted by nick2095, you can paste it into the scripting window in PowerShell ISE and run it. Alternately, you can run it using the regular PowerShell window, but you don't have as much control if something goes wrong.

    Be sure to replace the storage account name and key, container name, and blob name in those variables so it uses yours.

    Robin


    Sr. Content Developer at Microsoft

    Tuesday, July 5, 2016 6:03 PM
  • Hi All,

    Still, have a problem in deleting the virtual disk.

    The following storage account is having a snapshot and the following resource lease is in locked state.

    Please need your help.

    Thanks

    Santosh


    Thursday, August 18, 2016 6:31 AM