public MetricsClient(TokenCredential credential, MetricsClientOptions options) { Argument.AssertNotNull(credential, nameof(credential)); options ??= new MetricsClientOptions(); _clientDiagnostics = new ClientDiagnostics(options); _pipeline = HttpPipelineBuilder.Build(options, new BearerTokenAuthenticationPolicy(credential, "https://management.azure.com//.default")); _metricDefinitionsClient = new MetricDefinitionsRestClient(_clientDiagnostics, _pipeline); _metricsRestClient = new MetricsRestClient(_clientDiagnostics, _pipeline); _namespacesRestClient = new MetricNamespacesRestClient(_clientDiagnostics, _pipeline); }
/// <summary> /// Initializes a new instance of <see cref="MetricsQueryClient"/>. /// </summary> /// <param name="endpoint">The resource manager service endpoint to use. For example <c>https://management.azure.com/</c> for public cloud.</param> /// <param name="credential">The <see cref="TokenCredential"/> instance to use for authentication.</param> /// <param name="options">The <see cref="MetricsQueryClientOptions"/> instance to as client configuration.</param> public MetricsQueryClient(Uri endpoint, TokenCredential credential, MetricsQueryClientOptions options = null) { Argument.AssertNotNull(credential, nameof(credential)); options ??= new MetricsQueryClientOptions(); _clientDiagnostics = new ClientDiagnostics(options); var scope = $"{endpoint.AbsoluteUri}/.default"; Endpoint = endpoint; var pipeline = HttpPipelineBuilder.Build(options, new BearerTokenAuthenticationPolicy(credential, scope)); _metricDefinitionsClient = new MetricDefinitionsRestClient(_clientDiagnostics, pipeline, endpoint); _metricsRestClient = new MetricsRestClient(_clientDiagnostics, pipeline, endpoint); _namespacesRestClient = new MetricNamespacesRestClient(_clientDiagnostics, pipeline, endpoint); }
/// <summary> /// Initializes a new instance of <see cref="MetricsQueryClient"/>. /// </summary> /// <param name="endpoint">The resource manager service endpoint to use. For example <c>https://management.azure.com/</c> for public cloud.</param> /// <param name="credential">The <see cref="TokenCredential"/> instance to use for authentication.</param> /// <param name="options">The <see cref="MetricsQueryClientOptions"/> instance to as client configuration.</param> public MetricsQueryClient(Uri endpoint, TokenCredential credential, MetricsQueryClientOptions options = null) { Argument.AssertNotNull(credential, nameof(credential)); options ??= new MetricsQueryClientOptions(); _clientDiagnostics = new ClientDiagnostics(options); Endpoint = endpoint; var pipeline = HttpPipelineBuilder.Build(options, new BearerTokenAuthenticationPolicy( credential, $"{options.Audience ?? MetricsQueryClientAudience.AzureResourceManagerPublicCloud}//.default")); _metricDefinitionsClient = new MetricDefinitionsRestClient(_clientDiagnostics, pipeline, endpoint); _metricsRestClient = new MetricsRestClient(_clientDiagnostics, pipeline, endpoint); _namespacesRestClient = new MetricNamespacesRestClient(_clientDiagnostics, pipeline, endpoint); }