Reputation: 105
I have been trying to copy data from blobs in multiple batches referring the below code in powershell.
$MaxReturn = 10000
$ContainerName = "abc"
$Total = 0
$Token=New-Object -TypeName 'Microsoft.WindowsAzure.Storage.Blob.BlobContinuationToken'
$Token.NextMarker='last stored token value'
do
{
$Blobs = Get-AzureStorageBlob -Container $ContainerName -MaxCount $MaxReturn -ContinuationToken $Token
$Total += $Blobs.Count
if($Blobs.Length -le 0) { Break;}
$Token = $Blobs[$blobs.Count -1].ContinuationToken;
}
While ($Token -ne $Null)
Echo "Total $Total blobs in container $ContainerName"
I am saving the value of $Token after each batch in a file.I want to restart copying data from the continuation token which was last saved in the file.
To achieve this, i am manually replacing the line $Token=null with $Token="last saved token" and it throws me an error
"Cannot bind parameter 'ContinuationToken'. Cannot convert the value of type "System.String" to type "Microsoft.WindowsAzure.Storage.Blob.BlobContinuationToken".
How can i pass the value of last saved token to ContinuationToken parameter of Get-AzureStorageBlob ?
I have tried using
$Token=New-Object -TypeName Microsoft.WindowsAzure.Storage.Blob.BlobContinuationToken -NextMarker "Token value"
but it again throws an error
Cannot find type [Microsoft.WindowsAzure.Storage.Blob.BlobContinuationToken]: verify that the assembly containing this type is loaded.
Below is the powershell command to check for the same.
PS C:\Users\F\Documents> [Microsoft.WindowsAzure.Storage.Blob.BlobContinuationToken]
Upvotes: 0
Views: 426
Reputation: 105
Import-Module -Name AzureRM
$MaxReturn = 10000
$ContainerName = "abc"
$Total = 0
$Token=New-Object -TypeName 'Microsoft.WindowsAzure.Storage.Blob.BlobContinuationToken'
$Token.NextMarker='last stored token value'
do
{
$Blobs = Get-AzureStorageBlob -Container $ContainerName -MaxCount $MaxReturn -ContinuationToken $Token
$Total += $Blobs.Count
if($Blobs.Length -le 0) { Break;}
$Token = $Blobs[$blobs.Count -1].ContinuationToken;
}
While ($Token -ne $Null)
Echo "Total $Total blobs in container $ContainerName"
I needed to serialize the continuation token and import the AzureRM module to get the copy process start from the last value of continuation token. Thanks for all the help.
Upvotes: 1
Reputation: 743
This parameter is used for batches as i can find in documentation. So you can't convert it from any type to [Microsoft.WindowsAzure.Storage.Blob.BlobContinuationToken]
May be you find some help in link below, but i find that object have methods to write and read from xml file,so it's chanse to convert a serializable continuation token into its XML representation and then read it.
link1
Upvotes: 0