예제 #1
0
#pragma warning restore AZC0002 // Client method should have cancellationToken as the last optional parameter

        /// <summary>
        /// The SetBlobsAccessTierAsync operation sets the tier on blobs.  The
        /// operation is allowed on block blobs in a blob storage or general
        /// purpose v2 account.
        /// </summary>
        /// <param name="blobUris">
        /// URIs of the blobs to set the tiers of.
        /// </param>
        /// <param name="accessTier">
        /// Indicates the tier to be set on the blobs.
        /// </param>
        /// <param name="rehydratePriority">
        /// Optional <see cref="RehydratePriority"/>
        /// Indicates the priority with which to rehydrate an archived blob.
        /// </param>
        /// <param name="async">
        /// Whether to invoke the operation asynchronously.
        /// </param>
        /// <param name="cancellationToken">
        /// Optional <see cref="CancellationToken"/> to propagate notifications
        /// that the operation should be cancelled.
        /// </param>
        /// <returns>
        /// The <see cref="Response"/>s for the individual Set Tier operations.
        /// </returns>
        /// <remarks>
        /// A <see cref="RequestFailedException"/> will be thrown if
        /// a failure to submit the batch occurs.  Individual sub-operation
        /// failures will be wrapped in an <see cref="AggregateException"/>.
        /// </remarks>
        internal async Task <Response[]> SetBlobsAccessTierInteral(
            IEnumerable <Uri> blobUris,
            AccessTier accessTier,
            RehydratePriority?rehydratePriority,
            bool async,
            CancellationToken cancellationToken)
        {
            blobUris = blobUris ?? throw new ArgumentNullException(nameof(blobUris));
            var responses = new List <Response>();

            // Create the batch
            BlobBatch batch = CreateBatch();

            foreach (Uri uri in blobUris)
            {
                responses.Add(batch.SetBlobAccessTier(uri, accessTier, rehydratePriority));
            }

            // Submit the batch
            await SubmitBatchInternal(
                batch,
                true,
                async,
                cancellationToken)
            .ConfigureAwait(false);

            return(responses.ToArray());
        }
예제 #2
0
 public static BatchRehydratePriority?ToBatchRehydratePriority(this RehydratePriority?rehydratePriority)
 {
     if (rehydratePriority == null)
     {
         return(null);
     }
     return(new BatchRehydratePriority(rehydratePriority.ToString()));
 }
예제 #3
0
 public virtual Response[] SetBlobsAccessTier(
     IEnumerable <Uri> blobUris,
     AccessTier accessTier,
     RehydratePriority?rehydratePriority = default,
     CancellationToken cancellationToken = default) =>
 SetBlobsAccessTierInteral(
     blobUris,
     accessTier,
     rehydratePriority,
     false,     // async
     cancellationToken)
 .EnsureCompleted();
예제 #4
0
 public virtual async Task <Response[]> SetBlobsAccessTierAsync(
     IEnumerable <Uri> blobUris,
     AccessTier accessTier,
     RehydratePriority?rehydratePriority = default,
     CancellationToken cancellationToken = default) =>
 await SetBlobsAccessTierInteral(
     blobUris,
     accessTier,
     rehydratePriority,
     true,     // async
     cancellationToken)
 .ConfigureAwait(false);
예제 #5
0
        /// <summary>
        /// The <see cref="SetBlobAccessTier(Uri, AccessTier, RehydratePriority?, BlobRequestConditions)"/>
        /// operation sets the tier on a blob.  The operation is allowed on
        /// block blobs in a blob storage or general purpose v2 account.
        ///
        /// A block blob's tier determines Hot/Cool/Archive storage type.  This
        /// operation does not update the blob's ETag.  For detailed
        /// information about block blob level tiering
        /// <see href="https://docs.microsoft.com/en-us/azure/storage/blobs/storage-blob-storage-tiers">
        /// Blob Storage Tiers</see>.
        ///
        /// </summary>
        /// <param name="blobUri">
        /// The blob's primary <see cref="Uri"/> endpoint.
        /// </param>
        /// <param name="accessTier">
        /// Indicates the tier to be set on the blob.
        /// </param>
        /// <param name="rehydratePriority">
        /// Optional <see cref="RehydratePriority"/>
        /// Indicates the priority with which to rehydrate an archived blob.
        /// </param>
        /// <param name="leaseAccessConditions">
        /// Optional <see cref="BlobRequestConditions"/> to add conditions on
        /// setting the access tier.
        /// </param>
        /// <returns>
        /// A <see cref="Response"/> on successfully deleting.  The response
        /// cannot be used until the batch has been submitted with
        /// <see cref="BlobBatchClient.SubmitBatchAsync"/>.
        /// </returns>
        public virtual Response SetBlobAccessTier(
            Uri blobUri,
            AccessTier accessTier,
            RehydratePriority?rehydratePriority         = default,
            BlobRequestConditions leaseAccessConditions = default)
        {
            BlobUriBuilder uriBuilder = new BlobUriBuilder(blobUri);

            return(SetBlobAccessTier(
                       blobContainerName: uriBuilder.BlobContainerName,
                       blobName: uriBuilder.BlobName,
                       accessTier: accessTier,
                       rehydratePriority: rehydratePriority,
                       leaseAccessConditions: leaseAccessConditions));
        }
예제 #6
0
        /// <summary>
        /// The <see cref="SetBlobAccessTier(Uri, AccessTier, RehydratePriority?, BlobRequestConditions)"/>
        /// operation sets the tier on a blob.  The operation is allowed on
        /// block blobs in a blob storage or general purpose v2 account.
        ///
        /// A block blob's tier determines Hot/Cool/Archive storage type.  This
        /// operation does not update the blob's ETag.  For detailed
        /// information about block blob level tiering
        /// <see href="https://docs.microsoft.com/en-us/azure/storage/blobs/storage-blob-storage-tiers">
        /// Blob Storage Tiers</see>.
        ///
        /// </summary>
        /// <param name="blobUri">
        /// The blob's primary <see cref="Uri"/> endpoint.
        /// </param>
        /// <param name="accessTier">
        /// Indicates the tier to be set on the blob.
        /// </param>
        /// <param name="rehydratePriority">
        /// Optional <see cref="RehydratePriority"/>
        /// Indicates the priority with which to rehydrate an archived blob.
        /// </param>
        /// <param name="leaseAccessConditions">
        /// Optional <see cref="BlobRequestConditions"/> to add conditions on
        /// setting the access tier.
        /// </param>
        /// <returns>
        /// A <see cref="Response"/> on successfully deleting.  The response
        /// cannot be used until the batch has been submitted with
        /// <see cref="BlobBatchClient.SubmitBatchAsync"/>.
        /// </returns>
        public virtual Response SetBlobAccessTier(
            Uri blobUri,
            AccessTier accessTier,
            RehydratePriority?rehydratePriority         = default,
            BlobRequestConditions leaseAccessConditions = default)
        {
            SetBatchOperationType(BlobBatchOperationType.SetAccessTier);
            HttpMessage message = BatchRestClient.Blob.SetAccessTierAsync_CreateMessage(
                pipeline: _client.BatchOperationPipeline,
                resourceUri: blobUri,
                tier: accessTier,
                version: _client.Version.ToVersionString(),
                rehydratePriority: rehydratePriority,
                leaseId: leaseAccessConditions?.LeaseId);

            _messages.Add(message);
            return(new DelayedResponse(message, response => BatchRestClient.Blob.SetAccessTierAsync_CreateResponse(_client.ClientDiagnostics, response)));
        }
예제 #7
0
 internal BlobPropertiesInternal(DateTimeOffset?creationTime, DateTimeOffset lastModified, string etag, long?contentLength, string contentType, string contentEncoding, string contentLanguage, byte[] contentMD5, string contentDisposition, string cacheControl, long?blobSequenceNumber, BlobType?blobType, LeaseStatus?leaseStatus, LeaseState?leaseState, LeaseDurationType?leaseDuration, string copyId, CopyStatus?copyStatus, string copySource, string copyProgress, DateTimeOffset?copyCompletionTime, string copyStatusDescription, bool?serverEncrypted, bool?incrementalCopy, string destinationSnapshot, DateTimeOffset?deletedTime, int?remainingRetentionDays, AccessTier?accessTier, bool?accessTierInferred, ArchiveStatus?archiveStatus, string customerProvidedKeySha256, string encryptionScope, DateTimeOffset?accessTierChangeTime, int?tagCount, DateTimeOffset?expiresOn, bool?isSealed, RehydratePriority?rehydratePriority, DateTimeOffset?lastAccessedOn, DateTimeOffset?immutabilityPolicyExpiresOn, BlobImmutabilityPolicyMode?immutabilityPolicyMode, bool?legalHold)
 {
     CreationTime                = creationTime;
     LastModified                = lastModified;
     Etag                        = etag;
     ContentLength               = contentLength;
     ContentType                 = contentType;
     ContentEncoding             = contentEncoding;
     ContentLanguage             = contentLanguage;
     ContentMD5                  = contentMD5;
     ContentDisposition          = contentDisposition;
     CacheControl                = cacheControl;
     BlobSequenceNumber          = blobSequenceNumber;
     BlobType                    = blobType;
     LeaseStatus                 = leaseStatus;
     LeaseState                  = leaseState;
     LeaseDuration               = leaseDuration;
     CopyId                      = copyId;
     CopyStatus                  = copyStatus;
     CopySource                  = copySource;
     CopyProgress                = copyProgress;
     CopyCompletionTime          = copyCompletionTime;
     CopyStatusDescription       = copyStatusDescription;
     ServerEncrypted             = serverEncrypted;
     IncrementalCopy             = incrementalCopy;
     DestinationSnapshot         = destinationSnapshot;
     DeletedTime                 = deletedTime;
     RemainingRetentionDays      = remainingRetentionDays;
     AccessTier                  = accessTier;
     AccessTierInferred          = accessTierInferred;
     ArchiveStatus               = archiveStatus;
     CustomerProvidedKeySha256   = customerProvidedKeySha256;
     EncryptionScope             = encryptionScope;
     AccessTierChangeTime        = accessTierChangeTime;
     TagCount                    = tagCount;
     ExpiresOn                   = expiresOn;
     IsSealed                    = isSealed;
     RehydratePriority           = rehydratePriority;
     LastAccessedOn              = lastAccessedOn;
     ImmutabilityPolicyExpiresOn = immutabilityPolicyExpiresOn;
     ImmutabilityPolicyMode      = immutabilityPolicyMode;
     LegalHold                   = legalHold;
 }
예제 #8
0
        /// <summary>
        /// The SetBlobsAccessTierAsync operation sets the tier on blobs.  The
        /// operation is allowed on block blobs in a blob storage or general
        /// purpose v2 account.
        /// </summary>
        /// <param name="blobUris">
        /// URIs of the blobs to set the tiers of.
        /// </param>
        /// <param name="accessTier">
        /// Indicates the tier to be set on the blobs.
        /// </param>
        /// <param name="rehydratePriority">
        /// Optional <see cref="RehydratePriority"/>
        /// Indicates the priority with which to rehydrate an archived blob.
        /// </param>
        /// <param name="async">
        /// Whether to invoke the operation asynchronously.
        /// </param>
        /// <param name="cancellationToken">
        /// Optional <see cref="CancellationToken"/> to propagate notifications
        /// that the operation should be cancelled.
        /// </param>
        /// <returns>
        /// The <see cref="Response"/>s for the individual Set Tier operations.
        /// </returns>
        /// <remarks>
        /// A <see cref="RequestFailedException"/> will be thrown if
        /// a failure to submit the batch occurs.  Individual sub-operation
        /// failures will be wrapped in an <see cref="AggregateException"/>.
        /// </remarks>
        internal async Task <Response[]> SetBlobsAccessTierInteral(
            IEnumerable <Uri> blobUris,
            AccessTier accessTier,
            RehydratePriority?rehydratePriority,
            bool async,
            CancellationToken cancellationToken)
        {
            DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(BlobBatchClient)}.{nameof(SetBlobsAccessTier)}");

            try
            {
                scope.Start();

                blobUris = blobUris ?? throw new ArgumentNullException(nameof(blobUris));
                var responses = new List <Response>();

                // Create the batch
                BlobBatch batch = CreateBatch();
                foreach (Uri uri in blobUris)
                {
                    responses.Add(batch.SetBlobAccessTier(uri, accessTier, rehydratePriority));
                }

                // Submit the batch
                await SubmitBatchInternal(
                    batch,
                    true,
                    async,
                    cancellationToken)
                .ConfigureAwait(false);

                return(responses.ToArray());
            }
            catch (Exception ex)
            {
                scope.Failed(ex);
                throw;
            }
            finally
            {
                scope.Dispose();
            }
        }
예제 #9
0
        /// <summary>
        /// The <see cref="SetBlobAccessTier(string, string, AccessTier, RehydratePriority?, BlobRequestConditions)"/>
        /// operation sets the tier on a blob.  The operation is allowed on
        /// block blobs in a blob storage or general purpose v2 account.
        ///
        /// A block blob's tier determines Hot/Cool/Archive storage type.  This
        /// operation does not update the blob's ETag.  For detailed
        /// information about block blob level tiering see
        /// <see href="https://docs.microsoft.com/en-us/azure/storage/blobs/storage-blob-storage-tiers">
        /// Blob Storage Tiers</see>.
        /// </summary>
        /// <param name="blobContainerName">
        /// The name of the container containing the blob to set the tier of.
        /// </param>
        /// <param name="blobName">
        /// The name of the blob to set the tier of.
        /// </param>
        /// <param name="accessTier">
        /// Indicates the tier to be set on the blob.
        /// </param>
        /// <param name="leaseAccessConditions">
        /// Optional <see cref="BlobRequestConditions"/> to add conditions on
        /// setting the access tier.
        /// </param>
        /// <param name="rehydratePriority">
        /// Optional <see cref="RehydratePriority"/>
        /// Indicates the priority with which to rehydrate an archived blob.
        /// </param>
        /// <returns>
        /// A <see cref="Response"/> on successfully deleting.  The response
        /// cannot be used until the batch has been submitted with
        /// <see cref="BlobBatchClient.SubmitBatchAsync"/>.
        /// </returns>
        public virtual Response SetBlobAccessTier(
            string blobContainerName,
            string blobName,
            AccessTier accessTier,
            RehydratePriority?rehydratePriority         = default,
            BlobRequestConditions leaseAccessConditions = default)
        {
            var blobUri = new BlobUriBuilder(_client.Uri)
            {
                BlobContainerName = blobContainerName,
                BlobName          = blobName
            };

            return(SetBlobAccessTier(
                       blobUri.ToUri(),
                       accessTier,
                       rehydratePriority,
                       leaseAccessConditions));
        }
예제 #10
0
        /// <summary>
        /// The <see cref="SetBlobAccessTier(string, string, AccessTier, RehydratePriority?, BlobRequestConditions)"/>
        /// operation sets the tier on a blob.  The operation is allowed on
        /// block blobs in a blob storage or general purpose v2 account.
        ///
        /// A block blob's tier determines Hot/Cool/Archive storage type.  This
        /// operation does not update the blob's ETag.  For detailed
        /// information about block blob level tiering see
        /// <see href="https://docs.microsoft.com/en-us/azure/storage/blobs/storage-blob-storage-tiers">
        /// Blob Storage Tiers</see>.
        /// </summary>
        /// <param name="blobContainerName">
        /// The name of the container containing the blob to set the tier of.
        /// </param>
        /// <param name="blobName">
        /// The name of the blob to set the tier of.
        /// </param>
        /// <param name="accessTier">
        /// Indicates the tier to be set on the blob.
        /// </param>
        /// <param name="leaseAccessConditions">
        /// Optional <see cref="BlobRequestConditions"/> to add conditions on
        /// setting the access tier.
        /// </param>
        /// <param name="rehydratePriority">
        /// Optional <see cref="RehydratePriority"/>
        /// Indicates the priority with which to rehydrate an archived blob.
        /// </param>
        /// <returns>
        /// A <see cref="Response"/> on successfully deleting.  The response
        /// cannot be used until the batch has been submitted with
        /// <see cref="BlobBatchClient.SubmitBatchAsync"/>.
        /// </returns>
        public virtual Response SetBlobAccessTier(
            string blobContainerName,
            string blobName,
            AccessTier accessTier,
            RehydratePriority?rehydratePriority         = default,
            BlobRequestConditions leaseAccessConditions = default)
        {
            SetBatchOperationType(BlobBatchOperationType.SetAccessTier);

            HttpMessage message = BlobRestClient.CreateSetAccessTierRequest(
                containerName: blobContainerName,
                blob: blobName.EscapePath(),
                accessTier.ToBatchAccessTier(),
                timeout: null,
                rehydratePriority: rehydratePriority.ToBatchRehydratePriority(),
                leaseId: leaseAccessConditions?.LeaseId,
                ifTags: leaseAccessConditions?.TagConditions);

            _messages.Add(message);

            return(new DelayedResponse(
                       message,
                       async response =>
            {
                switch (response.Status)
                {
                case 200:
                case 202:
                    BlobSetAccessTierHeaders blobSetAccessTierHeaders = new BlobSetAccessTierHeaders(response);
                    return ResponseWithHeaders.FromValue(blobSetAccessTierHeaders, response);

                default:
                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response).ConfigureAwait(false);
                }
            }));
        }
 protected void ValidateBlobTier(BlobType type, PremiumPageBlobTier?pageBlobTier = null, StandardBlobTier?standardBlobTier = null, RehydratePriority?rehydratePriority = null)
 {
     if ((pageBlobTier != null) &&
         (type != BlobType.PageBlob))
     {
         throw new ArgumentOutOfRangeException("BlobType, PageBlobTier", String.Format("PremiumPageBlobTier can only be set to Page Blob. The Current BlobType is: {0}", type));
     }
     if ((standardBlobTier != null || rehydratePriority != null) &&
         (type != BlobType.BlockBlob))
     {
         throw new ArgumentOutOfRangeException("BlobType, StandardBlobTier/RehydratePriority", String.Format("StandardBlobTier and RehydratePriority can only be set to Block Blob. The Current BlobType is: {0}", type));
     }
 }
예제 #12
0
 public override Task <string> StartCopyAsync(Uri source, StandardBlobTier?standardBlockBlobTier, RehydratePriority?rehydratePriority, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken)
 {
     throw exception;
 }
예제 #13
0
        public static global::Azure.Storage.Blobs.Models.RehydratePriority?ConvertRehydratePriority_Track1ToTrack2(RehydratePriority? rehydratePriority)
        {
            if (rehydratePriority == null)
            {
                return(null);
            }

            switch (rehydratePriority)
            {
            case RehydratePriority.High:
                return(global::Azure.Storage.Blobs.Models.RehydratePriority.High);

            case RehydratePriority.Standard:
                return(global::Azure.Storage.Blobs.Models.RehydratePriority.Standard);

            default:
                return(null);
            }
        }
 /// <summary>
 /// Return a task that asynchronously start copy operation to a CloudBlockBlob with StandardBlobTier.
 /// </summary>
 /// <param name="blob">CloudBlob object whcih is a Block blob</param>
 /// <param name="source">Uri to copying source</param>
 /// <param name="premiumPageBlobTier">The StandardBlobTier of Destination blob</param>
 /// <param name="standardBlobTier">Access condition to source if it's file/blob in azure.</param>
 /// <param name="destAccessCondition">Access condition to Destination blob.</param>
 /// <param name="options">Blob request options</param>
 /// <param name="operationContext">Operation context</param>
 /// <param name="cmdletCancellationToken">Cancellation token</param>
 /// <returns>Return copy id if succeeded.</returns>
 public Task <string> StartCopyAsync(CloudBlob blob, Uri source, StandardBlobTier?standardBlobTier, RehydratePriority?rehydratePriority, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, XSCL.OperationContext operationContext, CancellationToken cancellationToken)
 {
     return(blob.StartCopyAsync(source, standardBlobTier, rehydratePriority, sourceAccessCondition, destAccessCondition, options, operationContext, cancellationToken));
 }
 /// <summary>
 /// Return a task that asynchronously set block blob Tier
 /// </summary>
 /// <param name="blob">CloudBlockBlob object</param>
 /// <param name="tier">block blob Tier</param>
 /// <param name="accessCondition">Access condition</param>
 /// <param name="options">Blob request options</param>
 /// <param name="operationContext">An object that represents the context for the current operation.</param>
 public Task SetStandardBlobTierAsync(CloudBlockBlob blob, AccessCondition accessCondition, StandardBlobTier tier, RehydratePriority?rehydratePriority, BlobRequestOptions options, XSCL.OperationContext operationContext, CancellationToken cmdletCancellationToken)
 {
     return(blob.SetStandardBlobTierAsync(tier, rehydratePriority, accessCondition, options, operationContext, cmdletCancellationToken));
 }
 public Task SetStandardBlobTierAsync(CloudBlockBlob blob, AccessCondition accessCondition, StandardBlobTier tier, RehydratePriority?rehydratePriority, BlobRequestOptions options, OperationContext operationContext, CancellationToken cmdletCancellationToken)
 {
     throw new NotImplementedException();
 }
예제 #17
0
 public static BlobItemProperties BlobItemProperties(
     bool accessTierInferred,
     bool?serverEncrypted,
     string contentType,
     string contentEncoding,
     string contentLanguage,
     byte[] contentHash,
     string contentDisposition,
     string cacheControl,
     long?blobSequenceNumber,
     BlobType?blobType,
     LeaseStatus?leaseStatus,
     LeaseState?leaseState,
     LeaseDurationType?leaseDuration,
     string copyId,
     CopyStatus?copyStatus,
     Uri copySource,
     string copyProgress,
     string copyStatusDescription,
     long?contentLength,
     bool?incrementalCopy,
     string destinationSnapshot,
     int?remainingRetentionDays,
     AccessTier?accessTier,
     DateTimeOffset?lastModified,
     ArchiveStatus?archiveStatus,
     string customerProvidedKeySha256,
     string encryptionScope,
     long?tagCount,
     DateTimeOffset?expiresOn,
     bool?isSealed,
     RehydratePriority?rehydratePriority,
     ETag?eTag,
     DateTimeOffset?createdOn,
     DateTimeOffset?copyCompletedOn,
     DateTimeOffset?deletedOn,
     DateTimeOffset?accessTierChangedOn)
 => new BlobItemProperties()
 {
     AccessTierInferred        = accessTierInferred,
     ServerEncrypted           = serverEncrypted,
     ContentType               = contentType,
     ContentEncoding           = contentEncoding,
     ContentLanguage           = contentLanguage,
     ContentHash               = contentHash,
     ContentDisposition        = contentDisposition,
     CacheControl              = cacheControl,
     BlobSequenceNumber        = blobSequenceNumber,
     BlobType                  = blobType,
     LeaseStatus               = leaseStatus,
     LeaseState                = leaseState,
     LeaseDuration             = leaseDuration,
     CopyId                    = copyId,
     CopyStatus                = copyStatus,
     CopySource                = copySource,
     CopyProgress              = copyProgress,
     CopyStatusDescription     = copyStatusDescription,
     ContentLength             = contentLength,
     IncrementalCopy           = incrementalCopy,
     DestinationSnapshot       = destinationSnapshot,
     RemainingRetentionDays    = remainingRetentionDays,
     AccessTier                = accessTier,
     LastModified              = lastModified,
     ArchiveStatus             = archiveStatus,
     CustomerProvidedKeySha256 = customerProvidedKeySha256,
     EncryptionScope           = encryptionScope,
     TagCount                  = tagCount,
     ExpiresOn                 = expiresOn,
     IsSealed                  = isSealed,
     RehydratePriority         = rehydratePriority,
     ETag                = eTag,
     CreatedOn           = createdOn,
     CopyCompletedOn     = copyCompletedOn,
     DeletedOn           = deletedOn,
     AccessTierChangedOn = accessTierChangedOn,
 };
 public Task <string> StartCopyAsync(CloudBlob blob, Uri source, StandardBlobTier?standardBlobTier, RehydratePriority?rehydratePriority, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken)
 {
     throw new NotImplementedException();
 }