You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit d405737
Browse filesBrowse the repository at this point in the historyBrowse files
Python: Support DefaultAzureCredential Auth for Azure Resources (microsoft#8711)
### Motivation and Context
For security best practices, we're moving away from api key based auth
for Azure resources like Azure OpenAI. Previously, all tests and samples
run with an api_key only, handled via the env var, the .env file, or
directly passed into the AzureChatCompletion constructor. If the api_key
is not found once the Azure Settings are loaded, we will attempt to
retrieve a token via the DefaultAzureCredential. If it succeeds, we use
the `ad_token`; otherwise, if the token is empty (meaning we failed to
retrieve it), Pydantic validation will fail as part of service
construction, just as it does today.
The user may configure a `TOKEN_ENDPOINT` (for example,
`AZURE_OPENAI_TOKEN_ENDPOINT`) to override the default token endpoint
used for AzureOpenAI, if required. This is also possible for the Python
Sessions Container Apps plugin via `ACA_TOKEN_ENDPOINT`, although the
default value is specified and works well if the user has the proper
role on the resource.
<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
1. Why is this change required?
2. What problem does it solve?
3. What scenario does it contribute to?
4. If it fixes an open issue, please link to the issue here.
-->
### Description
This PR:
- allows our GitHub integration tests to run off of the
DefaultAzureCredential.
- allows a user to retrieve a token via DefaultAzureCredential so they
don't need to manage api keys for Azure Resources.
- closes: microsoft#6512
<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [X] The code builds clean without any errors or warnings
- [X] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [X] All unit tests pass, and I have added new tests where possible
- [X] I didn't break anyone 😄
It is possible to add the code interpreter plugin as follows:
17
+
You can also provide the the `ACA_TOKEN_ENDPOINT` if you want to override the default value of `https://acasessions.io/.default`. If this token endpoint doesn't need to be overridden, then it is
18
+
not necessary to include this as an environment variable, in the .env file, or via the plugin's constructor. Please follow the [Azure Container Apps Documentation](https://learn.microsoft.com/en-us/azure/container-apps/sessions-code-interpreter) to review the proper role required to authenticate with the `DefaultAzureCredential`.
19
+
20
+
Next, let's move on to implementing the plugin in code. It is possible to add the code interpreter plugin as follows:
0 commit comments