Skip to content

foundry agent cannot use key auth#45056

Open
niuzheng168 wants to merge 1 commit intoAzure:mainfrom
niuzheng168:main
Open

foundry agent cannot use key auth#45056
niuzheng168 wants to merge 1 commit intoAzure:mainfrom
niuzheng168:main

Conversation

@niuzheng168
Copy link

Description

foundry agent cannot use key auth

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

@niuzheng168 niuzheng168 requested a review from rhurey as a code owner February 6, 2026 10:06
Copilot AI review requested due to automatic review settings February 6, 2026 10:06
@github-actions github-actions bot added Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization. Voice Live labels Feb 6, 2026
@github-actions
Copy link

github-actions bot commented Feb 6, 2026

Thank you for your contribution @niuzheng168! We will review the pull request and get back to you soon.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request attempts to enable Azure CLI credential authentication for the foundry agent sample, addressing an issue where the agent couldn't use key authentication. However, the implementation is incomplete and introduces API design inconsistencies.

Changes:

  • Added imports for AzureCliCredential and DefaultAzureCredential from azure.identity.aio
  • Changed the credential parameter type annotation to only accept AzureCliCredential or DefaultAzureCredential
  • Removed API key authentication logic and validation, hardcoding credential to AzureCliCredential()

self,
endpoint: str,
credential: Union[AzureKeyCredential, AsyncTokenCredential],
credential: Union[AzureCliCredential, DefaultAzureCredential],
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type annotation is too restrictive and inconsistent with the rest of the codebase. It should be Union[AzureKeyCredential, AsyncTokenCredential] to support both API key and token-based authentication methods. Other samples in this repository (async_function_calling_sample.py and basic_voice_assistant_async.py) use this more flexible type annotation, which allows users to choose their preferred authentication method.

Copilot uses AI. Check for mistakes.
Comment on lines +29 to +30
from azure.identity.aio import AzureCliCredential, DefaultAzureCredential

Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The imports AzureKeyCredential and AsyncTokenCredential (lines 50-51) are no longer used after removing API key authentication support. These unused imports should be removed to keep the code clean. However, if API key support is restored (as recommended), these imports should remain.

Copilot uses AI. Check for mistakes.
Comment on lines +548 to +549

credential = AzureCliCredential()
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoding the credential to only AzureCliCredential removes flexibility for users. The sample should support multiple authentication methods like other samples in this repository. Consider either: (1) keeping the commented-out options to show users both API key and token credential choices, or (2) adding a command-line parameter like basic_voice_assistant_async.py does with --use-token-credential flag. This would make the sample more useful and consistent with other samples in the codebase.

Suggested change
credential = AzureCliCredential()
# Choose the authentication method you want to use:
#
# Option 1: Use DefaultAzureCredential (recommended for most applications)
# This will use environment variables, managed identity, Visual Studio Code, Azure CLI, etc.
# from azure.identity.aio import DefaultAzureCredential
# credential = DefaultAzureCredential()
#
# Option 2: Use AzureCliCredential (for local development with an authenticated Azure CLI session)
credential = AzureCliCredential()
#
# Option 3: Use API key authentication
# Set the AZURE_VOICELIVE_API_KEY environment variable with your key.
# from azure.core.credentials import AzureKeyCredential
# credential = AzureKeyCredential(os.environ["AZURE_VOICELIVE_API_KEY"])

Copilot uses AI. Check for mistakes.
self,
endpoint: str,
credential: Union[AzureKeyCredential, AsyncTokenCredential],
credential: Union[AzureCliCredential, DefaultAzureCredential],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one is better from azure.core.credentials_async import AsyncTokenCredential

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

Labels

Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization. Voice Live

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants