如何使用 PowerShell 终止 Blob 存储中项目的租约?
当我尝试通过当前图像上传内容时,收到以下消息:
Add-AzureRmVhd : The remote server returned an error: (412) There is currently a lease on the blob and no lease ID was specified in the request..
At line:1 char:1
+ Add-AzureRmVhd -Destination $osDiskUri -LocalFilePath $localFileName ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Add-AzureRmVhd], StorageException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Compute.StorageServices.AddAzureVhdCommand
最佳答案
登录到旧门户并导航到虚拟机,然后图像选项卡,网址将为https://manage.windowsazure.com/@ yourname.onmicrosoft.com#Workspaces/VirtualMachineExtension/images。
选择该图像,然后选择底部的删除。
之后,转到您的存储并将其删除。
您还可以尝试以下操作,这将删除给定容器的 blob,然后删除该容器。
Add-AzureAccount
Get-AzureSubscription | Format-Table SubscriptionName, IsDefault, IsCurrent, CurrentStorageAccountName
$SubscriptionName = 'Your subsscription name'
Select-AzureSubscription -SubscriptionName $SubscriptionName
Get-AzureSubscription -Default
Get-AzureStorageAccount | Format-Table -Property StorageAccountName, Location, AccountType, StorageAccountStatus
$StorageAccountName = "Your storage account"
$StorageAccountKey = (Get-AzureStorageKey -StorageAccountName $StorageAccountName).Primary
$ContainerName = "Your container name"
$Context = New-AzureStorageContext -StorageAccountName $StorageAccountName -StorageAccountKey $StorageAccountKey
#Get a reference to all the blobs in the container.
$blobs = Get-AzureStorageBlob -Container $ContainerName -Context $Context
#Remove lease on each Blob
$blobs | %{$_.ICloudBlob.BreakLease()}
#Delete blobs in a specified container.
$blobs| Remove-AzureStorageBlob
Remove-AzureStorageContainer -Container $ContainerName -Context $Context
如果你想打破 Blob 上的密封,你可以使用 How to break the locked lease of blob storage in Microsoft Azure (PowerShell)
关于azure - 如何使用 PowerShell 终止 Azure 中 Blob 存储的租约?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35921299/