コード例 #1
0
 /// <summary>
 /// Convert BlobRehydratePriority to Azure's RehydratePriority.
 /// </summary>
 /// <param name="priority">The priority to convert.</param>
 /// <returns>A valid RehydratePriority</returns>
 public static RehydratePriority ToAzureEnum(this BlobRehydratePriority priority)
 {
     return((RehydratePriority)(int)priority);
 }
コード例 #2
0
        /// <inheritdoc/>
        public async Task <bool> ChangeBlobTierAsync(Uri blobUri, BlobAccessTier accessTier, BlobRehydratePriority rehydratePriority, StorageClientProviderContext context)
        {
            _ = blobUri ?? throw new ArgumentNullException(nameof(blobUri));
            _ = accessTier ?? throw new ArgumentNullException(nameof(accessTier));
            _ = context ?? throw new ArgumentNullException(nameof(context));

            IStorageBlobClientSleeve blobSleeve = _blobBaseClientProvider.GetBlobClientSleeveForUri(blobUri, context);

            Response response;

            try
            {
                response = await blobSleeve.Client.SetAccessTierAsync(accessTier.ToAzureEnum(), null, rehydratePriority.ToAzureEnum()).ConfigureAwait(false);
            }
            catch (Exception e)
            {
                _log.LogExceptionObject(LogEventIds.FailedToChangeTierInStorageService, e, blobUri);
                throw new GridwichStorageServiceException(blobUri, "Could not change tier of the blob.",
                                                          LogEventIds.FailedToChangeTierInStorageService, context.ClientRequestIdAsJObject, e);
            }

            if (response.Status == 200)
            {
                return(true);
            }

            _log.LogEventObject(LogEventIds.ChangeBlobTierUnexpectedResponse, new { blobUri, response });
            throw new GridwichStorageServiceException(blobUri, $"Unexpected response when changing the blob's tier: {response}",
                                                      LogEventIds.ChangeBlobTierUnexpectedResponse, context.ClientRequestIdAsJObject);
        }