/// <summary>
        /// On Task run successfully
        /// </summary>
        /// <param name="data">User data</param>
        protected override void OnTaskSuccessful(DataMovementUserData data)
        {
            StorageBlob.ICloudBlob blob         = data.Data as StorageBlob.ICloudBlob;
            IStorageBlobManagement localChannel = data.Channel;

            if (blob != null)
            {
                AccessCondition accessCondition = null;
                StorageBlob.BlobRequestOptions requestOptions = RequestOptions;

                if (BlobProperties != null || BlobMetadata != null)
                {
                    Task[] tasks = new Task[2];
                    tasks[0] = SetBlobProperties(localChannel, blob, BlobProperties);
                    tasks[1] = SetBlobMeta(localChannel, blob, BlobMetadata);
                    Task.WaitAll(tasks);
                }

                try
                {
                    localChannel.FetchBlobAttributesAsync(blob, accessCondition, requestOptions, OperationContext, CmdletCancellationToken).Wait();
                }
                catch (AggregateException e)
                {
                    StorageException storageException = e.InnerException as StorageException;
                    //Handle the limited read permission.
                    if (storageException == null || !storageException.IsNotFoundException())
                    {
                        throw e.InnerException;
                    }
                }

                WriteICloudBlobObject(data.TaskId, localChannel, blob);
            }
        }
        /// <summary>
        /// set blob properties
        /// </summary>
        /// <param name="azureBlob">ICloudBlob object</param>
        /// <param name="meta">blob properties hashtable</param>
        private async Task SetBlobProperties(IStorageBlobManagement localChannel, StorageBlob.ICloudBlob blob, Hashtable properties)
        {
            if (properties == null)
            {
                return;
            }

            foreach (DictionaryEntry entry in properties)
            {
                string key   = entry.Key.ToString();
                string value = entry.Value.ToString();
                Action <StorageBlob.BlobProperties, string> action = validICloudBlobProperties[key];

                if (action != null)
                {
                    action(blob.Properties, value);
                }
            }

            AccessCondition accessCondition = null;

            StorageBlob.BlobRequestOptions requestOptions = RequestOptions;

            await Channel.SetBlobPropertiesAsync(blob, accessCondition, requestOptions, OperationContext, CmdletCancellationToken);
        }
        /// <summary>
        /// set blob meta
        /// </summary>
        /// <param name="azureBlob">ICloudBlob object</param>
        /// <param name="meta">meta data hashtable</param>
        private async Task SetBlobMeta(IStorageBlobManagement localChannel, StorageBlob.ICloudBlob blob, Hashtable meta)
        {
            if (meta == null)
            {
                return;
            }

            foreach (DictionaryEntry entry in meta)
            {
                string key   = entry.Key.ToString();
                string value = entry.Value.ToString();

                if (blob.Metadata.ContainsKey(key))
                {
                    blob.Metadata[key] = value;
                }
                else
                {
                    blob.Metadata.Add(key, value);
                }
            }

            AccessCondition accessCondition = null;

            StorageBlob.BlobRequestOptions requestOptions = RequestOptions;

            await Channel.SetBlobMetadataAsync(blob, accessCondition, requestOptions, OperationContext, CmdletCancellationToken);
        }
        /// <summary>
        /// upload file to azure blob
        /// </summary>
        /// <param name="taskId">Task id</param>
        /// <param name="filePath">local file path</param>
        /// <param name="blob">destination azure blob object</param>
        internal virtual async Task Upload2Blob(long taskId, IStorageBlobManagement localChannel, string filePath, StorageBlob.ICloudBlob blob)
        {
            string         activity = String.Format(Resources.SendAzureBlobActivity, filePath, blob.Name, blob.Container.Name);
            string         status   = Resources.PrepareUploadingBlob;
            ProgressRecord pr       = new ProgressRecord(OutputStream.GetProgressId(taskId), activity, status);

            DataMovementUserData data = new DataMovementUserData()
            {
                Data    = blob,
                TaskId  = taskId,
                Channel = localChannel,
                Record  = pr
            };

            BlobUploadJob uploadJob = new BlobUploadJob()
            {
                DestBlob   = blob,
                SourcePath = filePath
            };

            await this.RunTransferJob(uploadJob, data);

            if (this.BlobProperties != null || this.BlobMetadata != null)
            {
                await TaskEx.WhenAll(
                    this.SetBlobProperties(localChannel, blob, this.BlobProperties),
                    this.SetBlobMeta(localChannel, blob, this.BlobMetadata));
            }

            try
            {
                await localChannel.FetchBlobAttributesAsync(
                    blob,
                    AccessCondition.GenerateEmptyCondition(),
                    this.RequestOptions,
                    this.OperationContext,
                    this.CmdletCancellationToken);
            }
            catch (StorageException e)
            {
                //Handle the limited read permission.
                if (!e.IsNotFoundException())
                {
                    throw;
                }
            }

            WriteICloudBlobObject(data.TaskId, localChannel, blob);
        }