-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Add code snippet to credential chains doc #49637
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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 PR adds a code example demonstrating the use of the DefaultAzureCredential constructor overload that accepts an environment variable name. The documentation is updated to provide a concrete code sample for readers.
- Adds a new code snippet (
snippet_DacEnvVar) showing how to use the constructor overload withDefaultEnvironmentVariableName. - Updates the markdown documentation to reference this new snippet in two locations where the constructor overload is mentioned.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| docs/azure/sdk/snippets/authentication/credential-chains/Program.cs | Adds new code snippet demonstrating DefaultAzureCredential constructor with environment variable parameter |
| docs/azure/sdk/authentication/credential-chains.md | Updates documentation date and adds references to new code snippet in two sections discussing environment variable usage |
| > The `AZURE_TOKEN_CREDENTIALS` environment variable supports individual credential names in `Azure.Identity` package versions 1.15.0 and later. | ||
| To ensure the environment variable is defined and set to a supported string, use constructor overload <xref:Azure.Identity.DefaultAzureCredential.%23ctor(System.String,Azure.Identity.DefaultAzureCredentialOptions)?displayProperty=name>. | ||
| To ensure the environment variable is defined and set to a supported string, use constructor overload <xref:Azure.Identity.DefaultAzureCredential.%23ctor(System.String,Azure.Identity.DefaultAzureCredentialOptions)?displayProperty=name>: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we validate the environment variable value no matter which approach you take. Should we reword this so that it says something like - "DefaultAzureCredential will validate the value set for the enviornmnent variable and will throw if validation fails."
Add a code sample showing how to pass the env var to the DAC ctor
Internal previews