Python: Removed usage of DefaultAzureCredential#12964
Merged
dmytrostruk merged 15 commits intomicrosoft:mainfrom Aug 25, 2025
Merged
Python: Removed usage of DefaultAzureCredential#12964dmytrostruk merged 15 commits intomicrosoft:mainfrom
dmytrostruk merged 15 commits intomicrosoft:mainfrom
Conversation
Collaborator
ekzhu
approved these changes
Aug 19, 2025
moonbox3
approved these changes
Aug 19, 2025
python/semantic_kernel/connectors/ai/open_ai/services/azure_chat_completion.py
Show resolved
Hide resolved
giles17
approved these changes
Aug 25, 2025
jcruzmot-te
pushed a commit
to thousandeyes/aia-semantic-kernel
that referenced
this pull request
Sep 15, 2025
### Motivation and Context <!-- 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. --> The usage of `DefaultAzureCredential` by default is unsafe and raises security issues. Instead, users should provide their own credential types such as `AzureCliCredential`, `ManagedIdentityCredential` and so on. More information here: https://learn.microsoft.com/en-us/python/api/azure-identity/azure.identity.aio?view=azure-python In this PR: 1. Removed the usage of `DefaultAzureCredential` from authentication logic. 2. Replaced `DefaultAzureCredential` with `AzureCliCredential` in all examples. **Note**: this is breaking change for Azure users, who relies on `DefaultAzureCredential`. Users will need to update the code and pass the credential type of their choice by using `credential` parameter when initializing one of the Azure clients. Before: ```python chat_completion = AzureChatCompletion() ``` After: ```python chat_completion = AzureChatCompletion(credential=AzureCliCredential()) ``` ### 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 - [ ] I didn't break anyone 😄
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
The usage of
DefaultAzureCredentialby default is unsafe and raises security issues. Instead, users should provide their own credential types such asAzureCliCredential,ManagedIdentityCredentialand so on. More information here:https://learn.microsoft.com/en-us/python/api/azure-identity/azure.identity.aio?view=azure-python
In this PR:
DefaultAzureCredentialfrom authentication logic.DefaultAzureCredentialwithAzureCliCredentialin all examples.Note: this is breaking change for Azure users, who relies on
DefaultAzureCredential. Users will need to update the code and pass the credential type of their choice by usingcredentialparameter when initializing one of the Azure clients.Before:
After:
Contribution Checklist