private static long ParseRangeTotalLength(string range)
        {
            int lengthSeparator = range.IndexOf("/", StringComparison.InvariantCultureIgnoreCase);

            if (lengthSeparator == -1)
            {
                throw BlobErrors.ParsingFullHttpRangeFailed(range);
            }
            return(long.Parse(range.Substring(lengthSeparator + 1), CultureInfo.InvariantCulture));
        }
        /// <summary>
        /// The <see cref="GetUserDelegationKeyInternal"/> operation retrieves a
        /// key that can be used to delegate Active Directory authorization to
        /// shared access signatures created with <see cref="Sas.BlobSasBuilder"/>.
        /// </summary>
        /// <param name="start">
        /// Start time for the key's validity, with null indicating an
        /// immediate start.  The time should be specified in UTC.
        /// </param>
        /// <param name="expiry">
        /// Expiration of the key's validity.  The time should be specified
        /// in UTC.
        /// </param>
        /// <param name="cancellationToken">
        /// Optional <see cref="CancellationToken"/> to propagate
        /// notifications that the operation should be cancelled.
        /// </param>
        /// <param name="async"/>
        /// <returns>
        /// A <see cref="Response{BlobServiceStatistics}"/> describing
        /// the service replication statistics.
        /// </returns>
        /// <remarks>
        /// A <see cref="StorageRequestFailedException"/> will be thrown if
        /// a failure occurs.
        /// </remarks>
        private async Task <Response <UserDelegationKey> > GetUserDelegationKeyInternal(
            DateTimeOffset?start,
            DateTimeOffset expiry,
            bool async,
            CancellationToken cancellationToken)
        {
            using (Pipeline.BeginLoggingScope(nameof(BlobServiceClient)))
            {
                Pipeline.LogMethodEnter(nameof(BlobServiceClient), message: $"{nameof(Uri)}: {Uri}");
                try
                {
                    if (start.HasValue && start.Value.Offset != TimeSpan.Zero)
                    {
                        throw BlobErrors.InvalidDateTimeUtc(nameof(start));
                    }

                    if (expiry.Offset != TimeSpan.Zero)
                    {
                        throw BlobErrors.InvalidDateTimeUtc(nameof(expiry));
                    }

                    var keyInfo = new KeyInfo {
                        Start = start, Expiry = expiry
                    };

                    return(await BlobRestClient.Service.GetUserDelegationKeyAsync(
                               Pipeline,
                               Uri,
                               keyInfo : keyInfo,
                               async : async,
                               operationName : Constants.Blob.Service.GetUserDelegationKeyOperationName,
                               cancellationToken : cancellationToken)
                           .ConfigureAwait(false));
                }
                catch (Exception ex)
                {
                    Pipeline.LogException(ex);
                    throw;
                }
                finally
                {
                    Pipeline.LogMethodExit(nameof(BlobServiceClient));
                }
            }
        }