internal TableServiceClient(Uri endpoint, TableSharedKeyPipelinePolicy policy, AzureSasCredential sasCredential, TablesClientOptions options)
        {
            Argument.AssertNotNull(endpoint, nameof(endpoint));

            _endpoint = endpoint;
            options ??= new TablesClientOptions();
            _isCosmosEndpoint = IsPremiumEndpoint(endpoint);
            var    perCallPolicies   = _isCosmosEndpoint ? new[] { new CosmosPatchTransformPolicy() } : Array.Empty <HttpPipelinePolicy>();
            var    endpointString    = endpoint.AbsoluteUri;
            string secondaryEndpoint = TableConnectionString.GetSecondaryUriFromPrimary(endpoint)?.AbsoluteUri;

            HttpPipelinePolicy authPolicy = sasCredential switch
            {
                null => policy,
                _ => new AzureSasCredentialSynchronousPolicy(sasCredential)
            };

            _pipeline = HttpPipelineBuilder.Build(
                options,
                perCallPolicies: perCallPolicies,
                perRetryPolicies: new[] { authPolicy },
                new ResponseClassifier());

            _version                    = options.VersionString;
            _diagnostics                = new TablesClientDiagnostics(options);
            _tableOperations            = new TableRestClient(_diagnostics, _pipeline, endpointString, _version);
            _serviceOperations          = new ServiceRestClient(_diagnostics, _pipeline, endpointString, _version);
            _secondaryServiceOperations = new ServiceRestClient(_diagnostics, _pipeline, secondaryEndpoint, _version);
        }
        internal TableServiceClient(Uri endpoint, TableSharedKeyPipelinePolicy policy, TableClientOptions options)
        {
            Argument.AssertNotNull(endpoint, nameof(endpoint));

            options ??= new TableClientOptions();
            var          endpointString    = endpoint.AbsoluteUri;
            string       secondaryEndpoint = TableConnectionString.GetSecondaryUriFromPrimary(endpoint)?.AbsoluteUri;
            HttpPipeline pipeline          = HttpPipelineBuilder.Build(options, policy);

            _version                    = options.VersionString;
            _diagnostics                = new ClientDiagnostics(options);
            _tableOperations            = new TableRestClient(_diagnostics, pipeline, endpointString, _version);
            _serviceOperations          = new ServiceRestClient(_diagnostics, pipeline, endpointString, _version);
            _secondaryServiceOperations = new ServiceRestClient(_diagnostics, pipeline, secondaryEndpoint, _version);
            _isPremiumEndpoint          = IsPremiumEndpoint(endpoint);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="TableServiceClient"/> using the specified <see cref="Uri" />.
        /// </summary>
        /// <param name="endpoint">
        /// A <see cref="Uri"/> referencing the table service account.
        /// This is likely to be similar to "https://{account_name}.table.core.windows.net/" or "https://{account_name}.table.cosmos.azure.com/".
        /// </param>
        /// <param name="tokenCredential">The <see cref="TokenCredential"/> used to authorize requests.</param>
        /// <param name="options">
        /// Optional client options that define the transport pipeline policies for authentication, retries, etc., that are applied to every request.
        /// </param>
        /// <exception cref="ArgumentNullException"><paramref name="endpoint"/> or <paramref name="tokenCredential"/> is null.</exception>
        public TableServiceClient(Uri endpoint, TokenCredential tokenCredential, TableClientOptions options = default)
        {
            Argument.AssertNotNull(endpoint, nameof(endpoint));
            Argument.AssertNotNull(tokenCredential, nameof(tokenCredential));

            _endpoint = endpoint;
            options ??= TableClientOptions.DefaultOptions;
            _isCosmosEndpoint = IsPremiumEndpoint(endpoint);
            var    perCallPolicies   = _isCosmosEndpoint ? new[] { new CosmosPatchTransformPolicy() } : Array.Empty <HttpPipelinePolicy>();
            var    endpointString    = endpoint.AbsoluteUri;
            string secondaryEndpoint = TableConnectionString.GetSecondaryUriFromPrimary(endpoint)?.AbsoluteUri;

            _pipeline = HttpPipelineBuilder.Build(
                options,
                perCallPolicies: perCallPolicies,
                perRetryPolicies: new[] { new BearerTokenAuthenticationPolicy(tokenCredential, TableConstants.StorageScope) },
                new ResponseClassifier());

            _version                    = options.VersionString;
            _diagnostics                = new TablesClientDiagnostics(options);
            _tableOperations            = new TableRestClient(_diagnostics, _pipeline, endpointString, _version);
            _serviceOperations          = new ServiceRestClient(_diagnostics, _pipeline, endpointString, _version);
            _secondaryServiceOperations = new ServiceRestClient(_diagnostics, _pipeline, secondaryEndpoint, _version);
        }