Dou*_*oug 6 azure azure-storage azure-storage-blobs azure-powershell
如何使用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
Run Code Online (Sandbox Code Playgroud)
登录到旧门户并导航到虚拟机,然后在图像选项卡中,网址将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
Run Code Online (Sandbox Code Playgroud)
如果你想打破blob上的封印,可以使用如何在Microsoft Azure中破坏blob存储的锁定租约(PowerShell)
租约可能来自虚拟机之类的东西,或者使用博客存储的其他东西。因此,手动释放租约可能会导致问题。
话虽如此,以下 PowerShell 命令应该可以解决问题:
Get-AzureRmStorageAccount -Name "STORAGE_ACCOUNT_NAME" | Get-AzureStorageBlob -name "CONTAINER_NAME").ICloudBlob.BreakLease()
Run Code Online (Sandbox Code Playgroud)
如果它是虚拟机,您应该看到以下有关删除磁盘的帖子: 无法删除 blob:当前 blob 上有租约,并且请求中未指定租约 ID
但是,如果您只是想替换使用给定 blob 的每台计算机所使用的驱动器,则停止 VM、释放租约、上传新映像并启动 VM 似乎可行。
| 归档时间: |
|
| 查看次数: |
8956 次 |
| 最近记录: |