Skip to content

azure.ai.agents - Introduce credential helper to validate auth issues up front#6668

Draft
JeffreyCA wants to merge 1 commit intoAzure:mainfrom
JeffreyCA:jeffreyca/ext-ai-agent-cred-validation
Draft

azure.ai.agents - Introduce credential helper to validate auth issues up front#6668
JeffreyCA wants to merge 1 commit intoAzure:mainfrom
JeffreyCA:jeffreyca/ext-ai-agent-cred-validation

Conversation

@JeffreyCA
Copy link
Contributor

Problem

Users in multi-tenant Azure environments can sometimes see a misleading error when deploying agents:

AzureDeveloperCLICredential: please run "azd auth login" from a command prompt to authenticate before using this credential

This occurs despite being logged in, because the Azure SDK's AzureDeveloperCLICredential broadly matches any error containing "azd auth login" and replaces it with a generic message.

Solution

Added early credential validation via a new azure.NewCredential() helper that:

  • Creates the credential with the correct tenant configuration
  • Immediately validates by calling GetToken() (token is cached for reuse)
  • Returns actionable error guidance when validation fails

New error message:

failed to authenticate for subscription '<sub>' in tenant '<tenant>'.
Suggestion: Visit this subscription in Azure Portal, then run `azd auth login`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant