Question

I'm uploading a file to blob storage using a CloudBlockBlob object and the UploadFromFileAsync method. When this is complete I will want to call a service which then tells several computers to get the file I uploaded. However, I notice that when I run this and then go check my files in the Azure portal that there is some lag in when it shows up. I don't know if this is because of the portal taking a while to reflect this or if the file is not actually there yet. This leads me to the real question then, can I check the progress of the file using this method? It would be nice to feed this in to a progress bar as well.

OTHER TIPS

In TPL, the way to report progress is via the IProgress<T> interface. Asynchronous methods which report progress are expected to provide an overload accepting an instance of this interface.

As the method doesn't have an overload and the API doesn't expose anything similar, I can only conclude that progress-reporting is not supported.

The Task returned by the method will itself indicate when the operation is complete, which you should await.

Looking into this some more, I noticed that the method returns a task, which I can check for complete status. However, this does not give me any indication of progress.

For who is still looking for this.

Here is an example to get uploading progress by progressHandler:

CancellationToken cancellationToken = new CancellationToken();
IProgress<StorageProgress> progressHandler = new Progress<StorageProgress>(
    progress => Console.WriteLine("Progress: {0} bytes transferred", progress.BytesTransferred)
    );

await blob.UploadFromStreamAsync(
    srcStream,
    default(AccessCondition),
    default(BlobRequestOptions),
    default(OperationContext),
    progressHandler,
    cancellationToken
    );

from https://docs.microsoft.com/en-us/dotnet/api/microsoft.azure.storage.core.util.storageprogress?view=azure-dotnet

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