我无法删除Azure blob,因为它上面有无限租约。 我现在正试图使用BreakLease()方法打破该租约。
以下是我在PowerShell中执行的命令:
$StorageAccountName = "storage account name"
$ContainerName = "container name"
$BlobName = "blob name
[Reflection.Assembly]::LoadFile("C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure\Azure.Storage\Microsoft.WindowsAzure.Storage.dll")
$Keys = Get-AzureStorageKey -StorageAccountName $StorageAccountName
$StorageAccountKey = $Keys[0].Primary
$Creds = New-Object Microsoft.WindowsAzure.Storage.Auth.StorageCredentials($StorageAccountName,$StorageAccountKey)
$CloudStorageAccount = New-Object Microsoft.WindowsAzure.Storage.CloudStorageAccount($Creds, $true)
$CloudBlobClient = $CloudStorageAccount.CreateCloudBlobClient()
$BlobContainer = $CloudBlobClient.GetContainerReference($ContainerName)
$Blob = $BlobContainer.ListBlobs() | Where{$_.Name -eq $BlobName}
$Blob.Properties
$Blob.BreakLease($(New-TimeSpan), $null, $null, $null)
blob属性输出为:
CacheControl :
ContentDisposition :
ContentEncoding :
ContentLanguage :
Length : 1098437886464
ContentMD5 :
ContentType : application/octet-stream
ETag : "0x8D33831477A9F90"
LastModified : 2/18/2016 7:01:09 AM +00:00
BlobType : PageBlob
LeaseStatus : Locked
LeaseState : Leased
LeaseDuration : Infinite
PageBlobSequenceNumber :
AppendBlobCommittedBlockCount :
BreakLease()方法调用的错误消息是:
Exception calling "BreakLease" with "4" argument(s): "The remote server returned an error: (409) Conflict."
At line:1 char:20
+ $Blob.BreakLease($(New-TimeSpan), $null, $null, $null)
+ ~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : StorageException
有什么想法吗?
答案 0 :(得分:0)
我认为您没有针对正确的资源类型。您在不同类型的资源上运行BreakLease
方法,而不是TypeName: Microsoft.WindowsAzure.Storage.Blob.CloudBlob
我在定位时遇到了同样的错误:
TypeName: Microsoft.WindowsAzure.Commands.Common.Storage.ResourceModel.AzureStorageBlob
答案 1 :(得分:0)
我遇到了与blob相同的问题,这些blob代表连接到Azure可用性集中的VM的VM磁盘。如果所有其他方法都失败了,我将更新我的加密脚本以检测VM是否在可用性集中,如果是,则使用以下过程:
HTH