/// <summary> /// Initializes a new instance of the <see cref="DocumentAnalysisClient"/> class. /// </summary> /// <param name="endpoint">The endpoint to use for connecting to the Form Recognizer Azure Cognitive Service.</param> /// <param name="credential">A credential used to authenticate to an Azure Service.</param> /// <param name="options">A set of options to apply when configuring the client.</param> /// <remarks> /// Both the <paramref name="endpoint"/> URI string and the <paramref name="credential"/> <c>string</c> key /// can be found in the Azure Portal. /// For more information see <see href="https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/formrecognizer/Azure.AI.FormRecognizer/README.md#authenticate-the-client"> here</see>. /// </remarks> public DocumentAnalysisClient(Uri endpoint, AzureKeyCredential credential, DocumentAnalysisClientOptions options) { Argument.AssertNotNull(endpoint, nameof(endpoint)); Argument.AssertNotNull(credential, nameof(credential)); options ??= new DocumentAnalysisClientOptions(); Diagnostics = new ClientDiagnostics(options); var pipeline = HttpPipelineBuilder.Build(options, new AzureKeyCredentialPolicy(credential, Constants.AuthorizationHeader)); ServiceClient = new DocumentAnalysisRestClient(Diagnostics, pipeline, endpoint.AbsoluteUri); }
/// <summary> /// Initializes a new instance of the <see cref="DocumentAnalysisClient"/> class. /// </summary> /// <param name="endpoint">The endpoint to use for connecting to the Form Recognizer Azure Cognitive Service.</param> /// <param name="credential">A credential used to authenticate to an Azure Service.</param> /// <param name="options">A set of options to apply when configuring the client.</param> /// <remarks> /// The <paramref name="endpoint"/> URI string can be found in the Azure Portal. /// For more information see <see href="https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/formrecognizer/Azure.AI.FormRecognizer/README.md#authenticate-the-client"> here</see>. /// </remarks> public DocumentAnalysisClient(Uri endpoint, TokenCredential credential, DocumentAnalysisClientOptions options) { Argument.AssertNotNull(endpoint, nameof(endpoint)); Argument.AssertNotNull(credential, nameof(credential)); options ??= new DocumentAnalysisClientOptions(); Diagnostics = new ClientDiagnostics(options); var pipeline = HttpPipelineBuilder.Build(options, new BearerTokenAuthenticationPolicy(credential, Constants.DefaultCognitiveScope)); ServiceClient = new DocumentAnalysisRestClient(Diagnostics, pipeline, endpoint.AbsoluteUri); }
/// <summary> /// Initializes a new instance of the <see cref="DocumentAnalysisClient"/> class. /// </summary> /// <param name="endpoint">The endpoint to use for connecting to the Form Recognizer Azure Cognitive Service.</param> /// <param name="credential">A credential used to authenticate to an Azure Service.</param> /// <param name="options">A set of options to apply when configuring the client.</param> /// <remarks> /// The <paramref name="endpoint"/> URI string can be found in the Azure Portal. /// For more information see <see href="https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/formrecognizer/Azure.AI.FormRecognizer/README.md#authenticate-the-client"> here</see>. /// </remarks> public DocumentAnalysisClient(Uri endpoint, TokenCredential credential, DocumentAnalysisClientOptions options) { Argument.AssertNotNull(endpoint, nameof(endpoint)); Argument.AssertNotNull(credential, nameof(credential)); options ??= new DocumentAnalysisClientOptions(); string defaultScope = $"{(string.IsNullOrEmpty(options.Audience?.ToString()) ? DocumentAnalysisAudience.AzurePublicCloud : options.Audience)}/.default"; Diagnostics = new ClientDiagnostics(options); var pipeline = HttpPipelineBuilder.Build(options, new BearerTokenAuthenticationPolicy(credential, defaultScope)); ServiceClient = new DocumentAnalysisRestClient(Diagnostics, pipeline, endpoint.AbsoluteUri); }