/// <summary> /// get blob content /// </summary> /// <param name="container">source container object</param> /// <param name="blobName">source blob name</param> /// <param name="fileName">destination file name</param> /// <returns>the downloaded AzureStorageBlob object</returns> internal void GetBlobContent(CloudBlobContainer container, string blobName, string fileName) { if (!NameUtil.IsValidBlobName(blobName)) { throw new ArgumentException(String.Format(Resources.InvalidBlobName, blobName)); } string filePath = GetFullReceiveFilePath(fileName, blobName, null); ValidatePipelineCloudBlobContainer(container); if (UseTrack2SDK()) { BlobContainerClient track2container = AzureStorageContainer.GetTrack2BlobContainerClient(container, Channel.StorageContext, ClientOptions); BlobBaseClient blobClient = track2container.GetBlobBaseClient(blobName); GetBlobContent(blobClient, filePath, true); } else { AccessCondition accessCondition = null; BlobRequestOptions requestOptions = RequestOptions; CloudBlob blob = GetBlobReferenceFromServerWithContainer(Channel, container, blobName, accessCondition, requestOptions, OperationContext); GetBlobContent(blob, filePath, true); } }
/// <summary> /// remove azure blob /// </summary> /// <param name="container">CloudBlobContainer object</param> /// <param name="blobName">blob name</param> /// <returns>true if the blob is removed successfully, false if user cancel the remove operation</returns> internal async Task RemoveAzureBlob(long taskId, IStorageBlobManagement localChannel, CloudBlobContainer container, string blobName) { if (!NameUtil.IsValidBlobName(blobName)) { throw new ArgumentException(String.Format(Resources.InvalidBlobName, blobName)); } ValidatePipelineCloudBlobContainer(container); AccessCondition accessCondition = null; BlobRequestOptions requestOptions = null; ICloudBlob blob = await localChannel.GetBlobReferenceFromServerAsync(container, blobName, accessCondition, requestOptions, OperationContext, CmdletCancellationToken); if (null == blob && container.ServiceClient.Credentials.IsSharedKey) { throw new ResourceNotFoundException(String.Format(Resources.BlobNotFound, blobName, container.Name)); } else { //Construct the blob as CloudBlockBlob no matter what's the real blob type //We can't get the blob type if Credentials only have the delete permission and don't have read permission. blob = container.GetBlockBlobReference(blobName); } await RemoveAzureBlob(taskId, localChannel, blob, true); }
/// <summary> /// get blob content /// </summary> /// <param name="containerName">source container name</param> /// <param name="blobName">source blob name</param> /// <param name="fileName">file name</param> /// <returns>the downloaded AzureStorageBlob object</returns> internal void GetBlobContent(string containerName, string blobName, string fileName) { if (!NameUtil.IsValidBlobName(blobName)) { throw new ArgumentException(String.Format(Resources.InvalidBlobName, blobName)); } if (!NameUtil.IsValidContainerName(containerName)) { throw new ArgumentException(String.Format(Resources.InvalidContainerName, containerName)); } CloudBlobContainer container = Channel.GetContainerReference(containerName); BlobRequestOptions requestOptions = RequestOptions; AccessCondition accessCondition = null; ICloudBlob blob = Channel.GetBlobReferenceFromServer(container, blobName, accessCondition, requestOptions, OperationContext); if (null == blob) { throw new ResourceNotFoundException(String.Format(Resources.BlobNotFound, blobName, containerName)); } GetBlobContent(blob, fileName, true); }
/// <summary> /// remove azure blob /// </summary> /// <param name="container">CloudBlobContainer object</param> /// <param name="blobName">blob name</param> /// <returns>true if the blob is removed successfully, false if user cancel the remove operation</returns> internal bool RemoveAzureBlob(CloudBlobContainer container, string blobName) { if (!NameUtil.IsValidBlobName(blobName)) { throw new ArgumentException(String.Format(Resources.InvalidBlobName, blobName)); } ValidatePipelineCloudBlobContainer(container); AccessCondition accessCondition = null; BlobRequestOptions requestOptions = RequestOptions; ICloudBlob blob = Channel.GetBlobReferenceFromServer(container, blobName, accessCondition, requestOptions, OperationContext); if (null == blob && container.ServiceClient.Credentials.IsSharedKey) { throw new ResourceNotFoundException(String.Format(Resources.BlobNotFound, blobName, container.Name)); } else { //Construct the blob as CloudBlockBlob no matter what's the real blob type //We can't get the blob type if Credentials only have the delete permission and don't have read permission. blob = container.GetBlockBlobReference(blobName); } return(RemoveAzureBlob(blob, true)); }
/// <summary> /// Check whether the blob name is valid. If not throw an exception /// </summary> /// <param name="name">Blob name</param> protected void ValidateBlobName(string name) { if (!NameUtil.IsValidBlobName(name)) { throw new ArgumentException(String.Format(Resources.InvalidBlobName, name)); } }
/// <summary> /// get blob content /// </summary> /// <param name="container">source container object</param> /// <param name="blobName">source blob name</param> /// <param name="fileName">destination file name</param> /// <returns>the downloaded AzureStorageBlob object</returns> internal void GetBlobContent(CloudBlobContainer container, string blobName, string fileName) { if (!NameUtil.IsValidBlobName(blobName)) { throw new ArgumentException(String.Format(Resources.InvalidBlobName, blobName)); } // Don't need get File full path here, since will get file full path in GetBlobContent() with blob object. ValidatePipelineCloudBlobContainer(container); if (UseTrack2Sdk()) { BlobContainerClient track2container = AzureStorageContainer.GetTrack2BlobContainerClient(container, Channel.StorageContext, ClientOptions); BlobBaseClient blobClient = track2container.GetBlobBaseClient(blobName); GetBlobContent(blobClient, fileName, true); } else { AccessCondition accessCondition = null; BlobRequestOptions requestOptions = RequestOptions; CloudBlob blob = GetBlobReferenceFromServerWithContainer(Channel, container, blobName, accessCondition, requestOptions, OperationContext); GetBlobContent(blob, fileName, true); } }
/// <summary> /// list blobs by blob name and container name /// </summary> /// <param name="containerName">container name</param> /// <param name="blobName">blob name pattern</param> /// <returns>An enumerable collection of IListBlobItem</returns> internal IEnumerable <IListBlobItem> ListBlobsByName(string containerName, string blobName) { CloudBlobContainer container = null; BlobRequestOptions requestOptions = null; AccessCondition accessCondition = null; bool useFlatBlobListing = true; string prefix = string.Empty; BlobListingDetails details = BlobListingDetails.Snapshots | BlobListingDetails.Metadata | BlobListingDetails.Copy; if (String.IsNullOrEmpty(blobName) || WildcardPattern.ContainsWildcardCharacters(blobName)) { container = GetCloudBlobContainerByName(containerName); IEnumerable <IListBlobItem> blobs = Channel.ListBlobs(container, prefix, useFlatBlobListing, details, requestOptions, OperationContext); WildcardOptions options = WildcardOptions.IgnoreCase | WildcardOptions.Compiled; WildcardPattern wildcard = null; if (!String.IsNullOrEmpty(blobName)) { wildcard = new WildcardPattern(blobName, options); } foreach (IListBlobItem blobItem in blobs) { ICloudBlob blob = blobItem as ICloudBlob; if (blob == null) { continue; } if (wildcard == null || wildcard.IsMatch(blob.Name)) { yield return(blob); } } } else { container = GetCloudBlobContainerByName(containerName, true); if (!NameUtil.IsValidBlobName(blobName)) { throw new ArgumentException(String.Format(Resources.InvalidBlobName, blobName)); } ICloudBlob blob = Channel.GetBlobReferenceFromServer(container, blobName, accessCondition, requestOptions, OperationContext); if (null == blob) { throw new ResourceNotFoundException(String.Format(Resources.BlobNotFound, blobName, containerName)); } else { yield return(blob); } } }
/// <summary> /// remove azure blob /// </summary> /// <param name="container">CloudBlobContainer object</param> /// <param name="blobName">blob name</param> /// <returns>true if the blob is removed successfully, false if user cancel the remove operation</returns> internal async Task RemoveAzureBlob(long taskId, IStorageBlobManagement localChannel, CloudBlobContainer container, string blobName) { if (!NameUtil.IsValidBlobName(blobName)) { throw new ArgumentException(String.Format(Resources.InvalidBlobName, blobName)); } ValidatePipelineCloudBlobContainer(container); if (!UseTrack2Sdk()) { AccessCondition accessCondition = null; BlobRequestOptions requestOptions = null; CloudBlob blob = null; try { blob = await localChannel.GetBlobReferenceFromServerAsync(container, blobName, this.SnapshotTime, accessCondition, requestOptions, OperationContext, CmdletCancellationToken).ConfigureAwait(false); } catch (InvalidOperationException) { blob = null; } if (null == blob && container.ServiceClient.Credentials.IsSharedKey) { throw new ResourceNotFoundException(String.Format(Resources.BlobNotFound, blobName, container.Name)); } else { //Construct the blob as CloudBlockBlob no matter what's the real blob type //We can't get the blob type if Credentials only have the delete permission and don't have read permission. blob = container.GetBlockBlobReference(blobName, this.SnapshotTime); } await RemoveAzureBlob(taskId, localChannel, blob, true).ConfigureAwait(false); } else { if (this.VersionId != null & this.SnapshotTime != null) { throw new ArgumentException("Can't input VersionId and SnapshotTime, since a blob can't have both."); } BlobContainerClient track2container = AzureStorageContainer.GetTrack2BlobContainerClient(container, localChannel.StorageContext, ClientOptions); BlobBaseClient blobClient = Util.GetTrack2BlobClient(track2container, blobName, localChannel.StorageContext, this.VersionId, null, this.SnapshotTime is null? null : this.SnapshotTime.Value.ToString("o"), ClientOptions); // Skip check blob existance, as Server will report error is necessary await RemoveAzureBlobTrack2(taskId, localChannel, blobClient, true).ConfigureAwait(false); } }
/// <summary> /// list blobs by blob name and container name /// </summary> /// <param name="containerName">container name</param> /// <param name="blobName">blob name pattern</param> /// <returns>An enumerable collection of IListBlobItem</returns> internal IEnumerable <Tuple <ICloudBlob, BlobContinuationToken> > ListBlobsByName(string containerName, string blobName) { CloudBlobContainer container = null; BlobRequestOptions requestOptions = RequestOptions; AccessCondition accessCondition = null; string prefix = string.Empty; if (String.IsNullOrEmpty(blobName) || WildcardPattern.ContainsWildcardCharacters(blobName)) { container = GetCloudBlobContainerByName(containerName); prefix = NameUtil.GetNonWildcardPrefix(blobName); WildcardOptions options = WildcardOptions.IgnoreCase | WildcardOptions.Compiled; WildcardPattern wildcard = null; if (!String.IsNullOrEmpty(blobName)) { wildcard = new WildcardPattern(blobName, options); } Func <ICloudBlob, bool> blobFilter = (blob) => wildcard == null || wildcard.IsMatch(blob.Name); IEnumerable <Tuple <ICloudBlob, BlobContinuationToken> > blobs = ListBlobsByPrefix(containerName, prefix, blobFilter); foreach (var blobInfo in blobs) { yield return(blobInfo); } } else { container = GetCloudBlobContainerByName(containerName, true); if (!NameUtil.IsValidBlobName(blobName)) { throw new ArgumentException(String.Format(Resources.InvalidBlobName, blobName)); } ICloudBlob blob = Channel.GetBlobReferenceFromServer(container, blobName, accessCondition, requestOptions, OperationContext); if (null == blob) { throw new ResourceNotFoundException(String.Format(Resources.BlobNotFound, blobName, containerName)); } else { yield return(new Tuple <ICloudBlob, BlobContinuationToken>(blob, null)); } } }
internal async Task SetBlobTag(long taskId, IStorageBlobManagement localChannel, CloudBlobContainer container, string blobName) { if (!NameUtil.IsValidBlobName(blobName)) { throw new ArgumentException(String.Format(Resources.InvalidBlobName, blobName)); } ValidatePipelineCloudBlobContainer(container); BlobContainerClient track2container = AzureStorageContainer.GetTrack2BlobContainerClient(container, this.Channel.StorageContext, ClientOptions); BlobBaseClient blobClient = Util.GetTrack2BlobClient(track2container, blobName, localChannel.StorageContext, null, false, null, ClientOptions); await SetBlobTag(taskId, localChannel, blobClient, true).ConfigureAwait(false); }
/// <summary> /// get blob content /// </summary> /// <param name="container">source container object</param> /// <param name="blobName">source blob name</param> /// <param name="fileName">destination file name</param> /// <returns>the downloaded AzureStorageBlob object</returns> internal void GetBlobContent(CloudBlobContainer container, string blobName, string fileName) { if (!NameUtil.IsValidBlobName(blobName)) { throw new ArgumentException(String.Format(Resources.InvalidBlobName, blobName)); } string filePath = GetFullReceiveFilePath(fileName, blobName, null); ValidatePipelineCloudBlobContainer(container); AccessCondition accessCondition = null; BlobRequestOptions requestOptions = RequestOptions; CloudBlob blob = GetBlobReferenceFromServerWithContainer(Channel, container, blobName, accessCondition, requestOptions, OperationContext); GetBlobContent(blob, filePath, true); }
/// <summary> /// Make sure the pipeline blob is valid and already existing /// </summary> /// <param name="blob">CloudBlob object</param> internal void ValidatePipelineCloudBlobTrack2(BlobBaseClient blob) { if (null == blob) { throw new ArgumentException(String.Format(Resources.ObjectCannotBeNull, typeof(CloudBlob).Name)); } if (!NameUtil.IsValidBlobName(blob.Name)) { throw new ArgumentException(String.Format(Resources.InvalidBlobName, blob.Name)); } if (!NameUtil.IsValidContainerName(blob.BlobContainerName)) { throw new ArgumentException(String.Format(Resources.InvalidContainerName, blob.BlobContainerName)); } }
/// <summary> /// list blobs by blob name and container name /// </summary> /// <param name="containerName">container name</param> /// <param name="blobName">blob name pattern</param> /// <returns>An enumerable collection of IListBlobItem</returns> internal async Task ListBlobsByName(long taskId, IStorageBlobManagement localChannel, string containerName, string blobName, bool includeDeleted = false) { CloudBlobContainer container = null; BlobRequestOptions requestOptions = RequestOptions; AccessCondition accessCondition = null; string prefix = string.Empty; if (String.IsNullOrEmpty(blobName) || WildcardPattern.ContainsWildcardCharacters(blobName) || includeDeleted) { container = await GetCloudBlobContainerByName(localChannel, containerName).ConfigureAwait(false); prefix = NameUtil.GetNonWildcardPrefix(blobName); WildcardOptions options = WildcardOptions.IgnoreCase | WildcardOptions.Compiled; WildcardPattern wildcard = null; if (!String.IsNullOrEmpty(blobName)) { wildcard = new WildcardPattern(blobName, options); } Func <CloudBlob, bool> blobFilter = (blob) => wildcard == null || wildcard.IsMatch(blob.Name); await ListBlobsByPrefix(taskId, localChannel, containerName, prefix, blobFilter, includeDeleted).ConfigureAwait(false); } else { container = await GetCloudBlobContainerByName(localChannel, containerName, true).ConfigureAwait(false); if (!NameUtil.IsValidBlobName(blobName)) { throw new ArgumentException(String.Format(Resources.InvalidBlobName, blobName)); } CloudBlob blob = await localChannel.GetBlobReferenceFromServerAsync(container, blobName, accessCondition, requestOptions, OperationContext, CmdletCancellationToken).ConfigureAwait(false); if (null == blob) { throw new ResourceNotFoundException(String.Format(Resources.BlobNotFound, blobName, containerName)); } else { WriteCloudBlobObject(taskId, localChannel, blob); } } }
/// <summary> /// remove azure blob /// </summary> /// <param name="container">CloudBlobContainer object</param> /// <param name="blobName">blob name</param> /// <returns>true if the blob is removed successfully, false if user cancel the remove operation</returns> internal bool RemoveAzureBlob(CloudBlobContainer container, string blobName) { if (!NameUtil.IsValidBlobName(blobName)) { throw new ArgumentException(String.Format(Resources.InvalidBlobName, blobName)); } ValidatePipelineCloudBlobContainer(container); AccessCondition accessCondition = null; BlobRequestOptions requestOptions = null; ICloudBlob blob = Channel.GetBlobReferenceFromServer(container, blobName, accessCondition, requestOptions, OperationContext); if (null == blob) { throw new ResourceNotFoundException(String.Format(Resources.BlobNotFound, blobName, container.Name)); } return(RemoveAzureBlob(blob, true)); }
/// <summary> /// Make sure the pipeline blob is valid and already existing /// </summary> /// <param name="blob">ICloudBlob object</param> internal void ValidatePipelineICloudBlob(ICloudBlob blob) { if (null == blob) { throw new ArgumentException(String.Format(Resources.ObjectCannotBeNull, typeof(ICloudBlob).Name)); } if (!NameUtil.IsValidBlobName(blob.Name)) { throw new ArgumentException(String.Format(Resources.InvalidBlobName, blob.Name)); } ValidatePipelineCloudBlobContainer(blob.Container); //BlobRequestOptions requestOptions = RequestOptions; //if (!Channel.DoesBlobExist(blob, requestOptions, OperationContext)) //{ // throw new ResourceNotFoundException(String.Format(Resources.BlobNotFound, blob.Name, blob.Container.Name)); //} }
/// <summary> /// get blob content /// </summary> /// <param name="container">source container object</param> /// <param name="blobName">source blob name</param> /// <param name="fileName">destination file name</param> /// <returns>the downloaded AzureStorageBlob object</returns> internal AzureStorageBlob GetBlobContent(CloudBlobContainer container, string blobName, string fileName) { if (!NameUtil.IsValidBlobName(blobName)) { throw new ArgumentException(String.Format(Resources.InvalidBlobName, blobName)); } string filePath = GetFullReceiveFilePath(fileName, blobName, null); ValidatePipelineCloudBlobContainer(container); AccessCondition accessCondition = null; BlobRequestOptions requestOptions = null; ICloudBlob blob = Channel.GetBlobReferenceFromServer(container, blobName, accessCondition, requestOptions, OperationContext); if (null == blob) { throw new ResourceNotFoundException(String.Format(Resources.BlobNotFound, blobName, container.Name)); } return(GetBlobContent(blob, filePath, true)); }
/// <summary> /// set azure blob content /// </summary> /// <param name="fileName">local file path</param> /// <param name="containerName">container name</param> /// <param name="blobName">blob name</param> /// <returns>null if user cancel the overwrite operation, otherwise return destination blob object</returns> internal void SetAzureBlobContent(string fileName, string blobName) { StorageBlob.BlobType type = StorageBlob.BlobType.BlockBlob; if (string.Equals(blobType, BlockBlobType, StringComparison.InvariantCultureIgnoreCase)) { type = StorageBlob.BlobType.BlockBlob; } else if (string.Equals(blobType, PageBlobType, StringComparison.InvariantCultureIgnoreCase)) { type = StorageBlob.BlobType.PageBlob; } else if (string.Equals(blobType, AppendBlobType, StringComparison.InvariantCultureIgnoreCase)) { type = StorageBlob.BlobType.AppendBlob; } else { throw new InvalidOperationException(string.Format( CultureInfo.CurrentCulture, Resources.InvalidBlobType, blobType, blobName)); } if (!string.IsNullOrEmpty(blobName) && !NameUtil.IsValidBlobName(blobName)) { throw new ArgumentException(String.Format(Resources.InvalidBlobName, blobName)); } string filePath = GetFullSendFilePath(fileName); bool isFile = UploadRequests.EnqueueRequest(filePath, type, blobName); if (!isFile) { WriteWarning(String.Format(Resources.CannotSendDirectory, filePath)); } }
/// <summary> /// list blobs by blob name and container name /// </summary> /// <param name="containerName">container name</param> /// <param name="blobName">blob name pattern</param> /// <returns>An enumerable collection of IListBlobItem</returns> internal async Task ListBlobsByName(long taskId, IStorageBlobManagement localChannel, string containerName, string blobName, bool includeDeleted = false, bool includeVersion = false) { CloudBlobContainer container = null; BlobRequestOptions requestOptions = RequestOptions; AccessCondition accessCondition = null; string prefix = string.Empty; if (String.IsNullOrEmpty(blobName) || WildcardPattern.ContainsWildcardCharacters(blobName) || includeDeleted) { container = await GetCloudBlobContainerByName(localChannel, containerName).ConfigureAwait(false); prefix = NameUtil.GetNonWildcardPrefix(blobName); WildcardOptions options = WildcardOptions.IgnoreCase | WildcardOptions.Compiled; WildcardPattern wildcard = null; if (!String.IsNullOrEmpty(blobName)) { wildcard = new WildcardPattern(blobName, options); } Func <string, bool> blobFilter = (blobNameToFilte) => wildcard == null || wildcard.IsMatch(blobNameToFilte); await ListBlobsByPrefix(taskId, localChannel, containerName, prefix, blobFilter, includeDeleted, IncludeVersion).ConfigureAwait(false); } else { container = await GetCloudBlobContainerByName(localChannel, containerName, true).ConfigureAwait(false); BlobContainerClient track2container = AzureStorageContainer.GetTrack2BlobContainerClient(container, localChannel.StorageContext, ClientOptions); if (!NameUtil.IsValidBlobName(blobName)) { throw new ArgumentException(String.Format(Resources.InvalidBlobName, blobName)); } BlobBaseClient blobClient = null; if (UseTrack2Sdk()) // User Track2 SDK { blobClient = Util.GetTrack2BlobClient(track2container, blobName, localChannel.StorageContext, this.VersionId, false, this.SnapshotTime is null ? null : this.SnapshotTime.Value.ToString("o"), ClientOptions); global::Azure.Storage.Blobs.Models.BlobProperties blobProperties; try { blobProperties = blobClient.GetProperties(BlobRequestConditions, cancellationToken: CmdletCancellationToken); } catch (global::Azure.RequestFailedException e) when(e.Status == 404) { throw new ResourceNotFoundException(String.Format(Resources.BlobNotFound, blobName, containerName)); } blobClient = Util.GetTrack2BlobClient(track2container, blobName, localChannel.StorageContext, this.VersionId, blobProperties.IsLatestVersion, this.SnapshotTime is null ? null : this.SnapshotTime.Value.ToString("o"), ClientOptions, blobProperties.BlobType); AzureStorageBlob outputBlob = new AzureStorageBlob(blobClient, localChannel.StorageContext, blobProperties, ClientOptions); OutputStream.WriteObject(taskId, outputBlob); } else // Use Track1 SDK { CloudBlob blob = await localChannel.GetBlobReferenceFromServerAsync(container, blobName, this.SnapshotTime, accessCondition, requestOptions, OperationContext, CmdletCancellationToken).ConfigureAwait(false); if (null == blob) { throw new ResourceNotFoundException(String.Format(Resources.BlobNotFound, blobName, containerName)); } else { OutputStream.WriteObject(taskId, new AzureStorageBlob(blob, localChannel.StorageContext, ClientOptions)); } } } }
/// <summary> /// set azure blob /// </summary> /// <param name="fileName">local file name</param> /// <param name="blob">destination blob</param> /// <param name="isValidContainer">whether the destination container is validated</param> /// <returns>null if user cancel the overwrite operation, otherwise return destination blob object</returns> internal AzureStorageBlob SetAzureBlobContent(string fileName, ICloudBlob blob, bool isValidContainer = false) { string filePath = GetFullSendFilePath(fileName); if (String.IsNullOrEmpty(filePath)) { return(null); } if (null == blob) { throw new ArgumentException(String.Format(Resources.ObjectCannotBeNull, typeof(ICloudBlob).Name)); } if (blob.BlobType == WindowsAzure.Storage.Blob.BlobType.PageBlob) { long fileSize = new FileInfo(filePath).Length; long pageBlobUnit = 512; long remainder = fileSize % pageBlobUnit; if (remainder != 0) { //the blob size must be a multiple of 512 bytes. throw new ArgumentException(String.Format(Resources.InvalidPageBlobSize, filePath, fileSize)); } } if (!NameUtil.IsValidBlobName(blob.Name)) { throw new ArgumentException(String.Format(Resources.InvalidBlobName, blob.Name)); } if (!isValidContainer) { ValidatePipelineCloudBlobContainer(blob.Container); } AccessCondition accessCondition = null; BlobRequestOptions requestOptions = null; ICloudBlob blobRef = Channel.GetBlobReferenceFromServer(blob.Container, blob.Name, accessCondition, requestOptions, OperationContext); if (null != blobRef) { if (blob.BlobType != blobRef.BlobType) { throw new ArgumentException(String.Format(Resources.BlobTypeMismatch, blobRef.Name, blobRef.BlobType)); } if (!overwrite) { if (!ConfirmOverwrite(blob.Name)) { return(null); } } } try { Upload2Blob(filePath, blob); Channel.FetchBlobAttributes(blob, accessCondition, requestOptions, OperationContext); } catch (Exception e) { WriteDebugLog(String.Format(Resources.Upload2BlobFailed, e.Message)); throw; } return(new AzureStorageBlob(blob)); }