I cannot remove Azure blob because it has an infinite rental. Now I am trying to break this contract using the BreakLease () method.
Here are the commands that I execute in 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)
The output of blob properties:
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 :
Error message when calling BreakLease () method:
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
Any ideas?
source share