Azure BreakLease返回409 Conflict错误

Pat*_*ick 5 azure azure-powershell

我无法删除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)
Run Code Online (Sandbox Code Playgroud)

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 :
Run Code Online (Sandbox Code Playgroud)

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
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

小智 0

我认为您没有针对正确类型的资源。您正在BreakLease不同类型的资源上运行该方法,而不是TypeName: Microsoft.WindowsAzure.Storage.Blob.CloudBlob

我在定位时遇到了同样的错误:

TypeName: Microsoft.WindowsAzure.Commands.Common.Storage.ResourceModel.AzureStorageBlob
Run Code Online (Sandbox Code Playgroud)