IT

임대 Blob이 포함 된 Azure 저장소 계정을 어떻게 삭제합니까?

lottoking 2020. 6. 8. 08:06
반응형

임대 Blob이 포함 된 Azure 저장소 계정을 어떻게 삭제합니까?


저는 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 Storage Explorer에서 Blob 자체 (30GB VHD)를 삭제하려고하면이 오류가 발생합니다.

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

따라서 내 평가에 따르면이 블롭이 임대되어 (이전에는 삭제 된 가상 머신에 의해)이 임대 ID를 얻을 수 없으면 삭제할 수 없습니다.

문제는이 Blob 및 결과적으로 저장소 계정을 어떻게 삭제할 수 있습니까?입니다.


솔루션의 핵심은 컨테이너에 활성 디스크 아티팩트가 있다는 메시지와이를 저장소에서 제거하라는 조언입니다.

Blob 저장소에서 디스크 이미지를 제거하는 절차는 다음과 같습니다.

  • Windows Azure 관리 포털로 이동하십시오 .
  • 가상 머신을 클릭하십시오.
  • 디스크를 클릭하십시오.
  • 디스크를 클릭하십시오.
  • 디스크 삭제를 클릭하십시오.

그런 다음 저장소 계정을 삭제할 수 있습니다.

노트:

  • 모든 가상 머신을 이미 삭제하고 0을 표시 한 경우에도 적용됩니다. 디스크 탭에는 여전히 아티팩트가 있습니다.
  • 디스크는 삭제 된 VM에서 비동기 적으로 분리되며이 필드를 지우려면 VM을 삭제 한 후 몇 분이 걸릴 수 있습니다.

참조 : VHD를 삭제할 수 없습니다.“현재 블롭에 임대가 있습니다…”


불행히도 스토리지를 삭제하기 전에 VM을 삭제했기 때문에 스토리지가 "고아"이므로 Fernando의 답변이 효과 가 없었습니다. 포털에서이를 수행하는 방법을 찾을 수 없으므로 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>


불행하게도 VM이 삭제되었지만 디스크에 삭제를 제외하고 Blob (30GB VHD)에 연결된 VM이 표시되는 경우가 있습니다. 또한 Azure 저장소 탐색기를 사용하는 경우 삭제할 수없는 Orfan이지만 임대 된 VHD Blob을 찾을 수 있으며 Preview Portal에는 참조가 없습니다.


가상 머신으로 이동 한 다음 디스크를 클릭하십시오. 디스크를 표시하고 하단에서 디스크 삭제를 선택하십시오. 해당 vhd를 유지하거나 삭제할지 여부를 선택할 수 있습니다.

스토리지를 통해 삭제하지 않도록 가상 머신을 통해 디스크를 먼저 삭제하는 것이 중요합니다.


Iaas Management Studio를 사용할 수 있습니다 . 임대를 중단하고 얼룩을 삭제 한 다음 고아 이미지를 제거하십시오.


제 경우에는 vmimage로 인해 스토리지를 삭제할 수 없습니다.

파워 쉘 명령 사용

get-azurevmimage | Where-Object-속성 범주 -in -Value "user"

삭제하려면 모든 이미지를 나열하는 모든 당신의 이미지는 다음과 같은 스크립트를 사용 :

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

FM이 이미 언급했듯이; VM을 삭제할 때 VM이 삭제 된 경우에도 디스크가 여전히 VM에 연결된 것으로 표시되는 시나리오가 있습니다.

For me this happened because I had a set a spending limit. When the spending limit is hit, your services are disabled. Any VPN gateways you have created and VMs will be deleted. Then to top it off the disks attached to the deleted VMs still think they are attached :(

I have found this blog that explains the issue and shows how to use powershell to resolve.

Hope this helps other users.


Sometimes we via the new portal to delete azure storage account, but we can’t delete it and get this error:” Failed to delete storage account 'jason1disks796'. Error: The storage account cannot be deleted due to its artifacts being in use.

We can use PowerShell to list all the VHD blobs of the storage account(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

If your storage account is in the ASM module, you can use this script to remove storage account:

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

Besides, there is another scenario, there is no container or blob in this storage account (an empty storage account, we can’t find blob or container in this storage account via PowerShell or portal), when we use portal to delete the storage account, and the error message” Failed to delete storage account 'jason1disks796'. Error: The storage account cannot be deleted due to its artifacts being in use”. In this scenario we can create a new VM and specify the storage account to the problematic Storage Account, then delete it again.


Do check before deleting your storage account; there must be the associated virtual machine(s), Disks and Images for each storage account you created. Go to Azure portal

Select Virtual Machines tab on left pane Click on Instances Images and Disks

Note that, Individual Virtual machines has its attached disks which show on Disks area.Before deleting a Virtual machine, delete the associated disks first and delete the virtual machine has the disk second.Then delete the storage account last. Also look out for Network in the same left-hand side pane if any associated with the account you want to delete.

In the new updated Azure portal, many of the above-stated config pages are changed. You can see Images and Disks options in "All resources" pane. In the newer version of an Azure portal, you can easily identify VMs its associated Disks and its Storage account clearly on its adjacent vertical panes all in one page with different icon images.


For those who rely on GUI to manage Azure and have no idea to use PowerShell or do the other answers, you can now delete the stuck storage account by checking "Delete unattached images" when trying to delete the storage.

It will automatically delete the storage without much hassle.

참고URL : https://stackoverflow.com/questions/10969012/how-do-i-delete-an-azure-storage-account-containing-a-leased-blob

반응형