azure - 如何使用 PowerShell 终止 Azure 中 Blob 存储的租约?

标签 azure azure-storage azure-blob-storage 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

最佳答案

登录到旧门户并导航到虚拟机,然后图像选项卡,网址将为https://manage.windowsazure.com/@ yourname.onmicrosoft.com#Workspaces/VirtualMachineExtension/images。 选择该图像,然后选择底部的删除

enter image description here

之后,转到您的存储并将其删除。

您还可以尝试以下操作,这将删除给定容器的 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/

相关文章:

azure - 降低 Azure 存储上的文件托管站点的出站带宽成本?

Azure函数: Why do I see two w3wp processes in Kudu?

azure-storage - 在 Azure 网站中存储上传的文件 : File System or Azure Storage

asp.net - 通过构建管道将 ASP.NET 应用程序部署到 Azure 应用服务

android - android 的窗口 azure 移动服务根据不同的值获取多条记录

Azure 存储错误 : "The specified blob already exists", 但事实并非如此!

Azure blob 容器共享访问签名即将到期

c# - 如何验证 Azure 存储 blob 名称

azure - Windows 10 驱动程序签名自动化

c# - Botframework v4 所有用户的状态相同 C#