Skip to content

[BUG] Unable to Authenticate AzureDocumentIntelligenceClient on AzureGovernment #48524

Open
@coryisakson

Description

@coryisakson

Library name and version

Azure.AI.DocumentIntelligence 1.0.0

Describe the bug

API calls result in an error when deployed to AzureGovernment.

I am using the DocumentIntelligenceClient and DefaultAzureCredential

The SDK client currently uses a hardcoded Scopes value that points to the Public cloud.

https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/documentintelligence/Azure.AI.DocumentIntelligence/src/Generated/DocumentIntelligenceClient.cs#L89

Please provide an option to set the Audience like most other Azure Clients offer in their Options/ConfigureOptions. Alternatively detect which cloud the service is running on and set the Scopes string to match.

Expected behavior

Client operations such as AnalyzeDocumentAsync succeed without 401 authentication errors

Actual behavior

Error Details
Unauthorized. Access token is missing, invalid, audience is incorrect (https://cognitiveservices.azure.us), or have expired. Status: 401 (Unauthorized) Content: { "statusCode": 401, "message": "Unauthorized. Access token is missing, invalid, audience is incorrect (https://cognitiveservices.azure.us), or have expired." }

Reproduction Steps

Deploy Document Intelligence service in AzureGovernment and capture the endpoint.

Execute the following code from an App Service hosted in AzureGovernment

var _client = new DocumentIntelligenceClient(new Uri("https://.cognitiveservices.azure.us/"), new DefaultAzureCredential());

var operation = await _client.AnalyzeDocumentAsync(WaitUntil.Completed, analyzeDocumentOptions, cancellationToken);

Environment

Azure AppService running .net core 8 on Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    ClientThis issue is related to a non-management packageCognitive - Form RecognizerService AttentionWorkflow: This issue is responsible by Azure service team.customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions