首页 文章

如何删除包含租用blob的Azure存储帐户?

提问于
浏览
150

我正在使用Windows Azure持久虚拟机 . 最后,我删除了虚拟机(成功)并尝试删除关联的存储帐户 .

删除存储帐户的请求失败 .

在删除存储帐户时,在预览门户(manage.windowsazure.com)上出现此错误:

Failed to delete Storage account 'portalvhdscwtwycpsxxxxx'

Details:

Storage account portalvhdscwtwycpsxxxxx has 1 container(s) which have an active image and/or disk artifacts. Ensure those artifacts are removed from the image repository before deleting this storage account.

在以前的门户网站(windows.azure.com)上,我收到此错误:

Submit Failed

Storage account portalvhdscwtwycpsxxxxx has 1 container(s) which have an active image and/or disk artifacts. Ensure those artifacts are removed from the image repository before deleting this storage account.

尝试在Azure存储资源管理器上删除blob本身(30GB VHD)我收到此错误:

There is currently a lease on the blob and no lease ID was specified in the request.

所以我的评估是这个blob是租用的(由之前的,现在删除的虚拟机),我不能删除它,除非我可以得到这个租约ID .

问题是:如何删除此Blob,从而删除存储帐户?

9 回答

  • 16

    解决方案的关键是容器具有活动磁盘工件的消息以及从存储库中删除它的建议 .

    从blob存储库中删除磁盘映像的过程是:

    之后,可以删除存储帐户 .

    笔记:

    • 即使您已经删除了所有虚拟机并且显示0,这也适用;磁盘选项卡下仍会有工件 .

    • 磁盘与已删除的VM异步分离,删除VM后可能需要几分钟才能清除此字段 .

    另见:Unable to delete VHD, “There is currently a lease on the blob…”

  • 12

    不幸的是,Fernando's answer没有找到从门户网站上执行此操作的方法,因此我安装了azure-cli,并在身份验证后运行了以下命令:

    azure storage account delete <my-account>
    

    这失败了,错误信息包含罪魁祸首的名字,例如:

    error: Storage account <my-account> has some active image(s) and/or disk(s), e.g. <my-image>. Ensure these image(s) and/or disk(s) are removed before deleting this storage

    然后我删除了有问题的图像

    azure vm disk delete <my-image>

    并再次尝试删除存储,这次成功 .

    azure storage account delete <my-account>

  • 8

    不幸的是,有些虚拟机被删除但是磁盘显示连接到blob的VM(30GB VHD),导致删除 . 此外,还有一种情况是使用Azure存储资源管理器,您可以找到无法删除的orfan但租用的VHD blob,并且预览门户上没有引用 .

  • 4

    转到虚拟机,然后单击光盘 . 标记光盘并选择底部的删除光盘 . 您现在可以选择是要保留还是删除相应的vhd .

    首先必须通过虚拟机删除光盘,不要通过存储删除 .

  • 5

    您可以使用Iaas Management Studio:中断租约,删除blob,然后删除孤立图像 .

  • 0

    在我的情况下,由于vmimages,无法删除存储 .

    使用power shell命令

    get-azurevmimage | Where-Object -Property Category -in -Value "user"

    列出所有图像要删除 ALL YOU IMAGES ,请使用以下脚本:

    get-azurevmimage | Where-Object -Property Category -in -Value "user" |   
    foreach {
            echo "remove $($_.ImageName)"
            Remove-AzureVMImage –ImageName $($_.ImageName)
            }
    
  • 328

    作为F.M.已经说过;有一种情况是,当删除VM时,即使VM已被删除,磁盘仍显示为连接到VM .

    对我而言,这是因为我设定了支出限额 . 达到支出限额后,您的服务将被禁用 . 您创建的任何VPN网关和VM都将被删除 . 然后顶部附加到已删除的VM的磁盘仍然认为它们是附加的:(

    我找到this blog解释了这个问题,并展示了如何使用powershell来解决问题 .

    希望这有助于其他用户 .

  • 5

    有时我们通过新门户删除azure存储帐户,但我们无法删除它并收到此错误:“无法删除存储帐户'jason1disks796' . 错误: The storage account cannot be deleted due to its artifacts being in use.

    我们可以使用PowerShell列出存储帐户的所有VHD blob( ARM module ):

    PS > Login-AzureRmAccount
    PS > $RGName = "jason1"
    PS > $SAName = "jason1disks796"
    PS > $ConName = "vhds"
    PS > $TempObj = New-Object -TypeName PSCustomObject
    PS > $TempObj |Add-Member -Name BlobName -MemberType NoteProperty -Value $null
    PS > $TempObj |Add-Member -Name LeaseState -MemberType NoteProperty -Value $null
    PS > $Keylist = Get-AzureRmStorageAccountKey -ResourceGroupName $RGName -StorageAccountName $SAName
    PS > $Key = $Keylist[0].Value
    PS > $Ctx = New-AzureStorageContext -StorageAccountName $SAName -StorageAccountKey $Key
    PS > Get-AzureStorageContainer -Context $ctx
    CloudBlobContainer : Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer
    Permission         : Microsoft.WindowsAzure.Storage.Blob.BlobContainerPermissions
    PublicAccess       : Off
    LastModified       : 1/19/2017 1:27:21 AM +00:00
    ContinuationToken  :
    Context            : Microsoft.WindowsAzure.Commands.Common.Storage.AzureStorageContext
    Name               : vhds
    PS > $List = Get-AzureStorageBlob -Blob *.vhd -Container $ConName -Context $Ctx
    PS > $List | ForEach-Object { $TempObj.BlobName = $_.Name; $TempObj.LeaseState = $_.ICloudBlob.Properties.LeaseState; $TempObj }
    
    BlobName              LeaseState
    --------              ----------
    SQL20170119092405.vhd     Leased
    
    PS > Get-AzureStorageBlob -Blob * -Container $con -Context $ctx | Remove-AzureStorageBlob
    PS > Remove-AzureRmStorageAccount -ResourceGroupName $RGname -Name $SAName
    

    如果您的存储帐户位于 ASM module 中,则可以使用此脚本删除存储帐户:

    Add-AzureAccount
    $SAName = "jason1161"
    $ConName = "vhds"
    $TempObj = New-Object -TypeName PSCustomObject
    $TempObj |Add-Member -Name BlobName -MemberType NoteProperty -Value $null
    $TempObj |Add-Member -Name LeaseState -MemberType NoteProperty -Value $null
    $Keylist = Get-AzureStorageKey -StorageAccountName $SAName
    $Key = $Keylist.primary
    $Ctx = New-AzureStorageContext -StorageAccountName $SAName -StorageAccountKey $Key
    $List = Get-AzureStorageBlob -Blob *.vhd -Container $ConName -Context $Ctx
    $List | ForEach-Object { $TempObj.BlobName = $_.Name; $TempObj.LeaseState = $_.ICloudBlob.Properties.LeaseState; $TempObj }
    PS > Get-AzureStorageBlob -Blob * -Container $con -Context $ctx | Remove-AzureStorageBlob
    PS > Remove-AzureStorageAccount -Name $SAName
    

    此外,还有另一种情况,当我们使用门户删除存储帐户时,此存储帐户中没有容器或blob( an empty storage account ,我们无法通过PowerShell或门户在此存储帐户中找到blob或容器)错误消息“无法删除存储帐户'jason1disks796' . 错误:由于其工件正在使用,因此无法删除存储帐户“ . In this scenario we can create a new VM and specify the storage account to the problematic Storage Account, then delete it again.

  • 0

    在删除存储帐户之前进行检查;您创建的每个存储帐户必须有关联的虚拟机,磁盘和映像 . 转到Azure门户

    在左窗格中选择虚拟机选项卡单击实例图像和磁盘

    请注意,单个虚拟机具有其附加的磁盘在磁盘区域显示 . 删除虚拟机之前,先删除关联的磁盘,然后删除磁盘次要的虚拟机 . 然后删除最后一个存储帐户 . 如果与要删除的帐户相关联,请在同一左侧窗格中查找“网络” .

    在新更新的Azure门户中,许多上述配置页面都已更改 . 您可以在“所有资源”窗格中查看“图像和磁盘”选项 . 在较新版本的Azure门户中,您可以在一个页面中使用不同的图标图像轻松地在其相邻的垂直窗格中清楚地识别其关联的磁盘及其存储帐户的VM .

相关问题