Question

I'm trying to invoke Add-Blob Azure cmdlet

Add-Blob -BlobType Block -FilePath $packagePath -ContainerName $blobContainerName

and it has been working just fine until recently but now it fails with

Operation could not be completed within the specified time.

message. I suspect that for whatever reason the upload speed has got really low and so it just doesn't manage to upload the file fast enough.

Is it possible to increase the timeout value for that operation?

Was it helpful?

Solution

Are you using the Cmdlets from http://wappowershell.codeplex.com? Please note that these cmdlets are now (kind of) deprecated and have been replaced by Windows Azure Management Cmdlets (http://msdn.microsoft.com/en-us/library/windowsazure/jj554330.aspx). Unfortunately, the cmdlet to add blob is not there in the new cmdlets.

Coming back to your question, I don't think it's possible to specify the request timeout with this Cmdlet and there's no source code available on CodePlex site for you to modify. What you could do is invoke Storage Client library directly through PowerShell. I took the liberty of modifying the code from this blog post (http://www.fsmpi.uni-bayreuth.de/~dun3/archives/uploading-a-file-to-azure-blob-storage-from-powershell/528.html) and included support for Timeout parameter there:

    Add-Type -Path "C:\Program Files\Microsoft SDKs\Windows Azure\.NET SDK\2012-06\ref\Microsoft.WindowsAzure.StorageClient.dll"

    $accountName = "<your account name>";

    $accountKey = "<your account key>";

    $blobContainerName = "<your blob container name>";

    $fullFilePath = "<Full path of the file you wish to upload>";

    $requestTimeoutInSeconds = 600;

    $cloudStorageAccountNameAndKey = new-object Microsoft.WindowsAzure.StorageCredentialsAccountAndKey($accountName, $accountKey);

    $cloudStorageAccount = new-object Microsoft.WindowsAzure.CloudStorageAccount($cloudStorageAccountNameAndKey, $true);

    $cloudBlobClient = [Microsoft.WindowsAzure.StorageClient.CloudStorageAccountStorageClientExtensions]::CreateCloudBlobClient($cloudStorageAccount)

    $blobContainer = $cloudBlobClient.GetContainerReference($blobContainerName);

$blobContainer.CreateIfNotExist();

    $blockBlob = $blobContainer.GetBlockBlobReference("<blob name>");

    $blobRequestOptions = new-object Microsoft.WindowsAzure.StorageClient.BlobRequestOptions;

    $blobRequestOptions.Timeout = [TimeSpan]::FromSeconds($requestTimeoutInSeconds);

    $blockBlob.UploadFile($fullFilePath, $blobRequestOptions);

If you're looking for alternatives to Microsoft's PowerShell Cmdlets, may I suggest you take a look at Cerebrata Azure Management Cmdlets [I'm one of the devs for this product]. It has cmdlets for complete storage management and service management.

Hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top