Skip to content

Conversation

dmytrostruk
Copy link
Member

@dmytrostruk dmytrostruk commented Aug 19, 2025

Motivation and Context

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:

chat_completion = AzureChatCompletion()

After:

chat_completion = AzureChatCompletion(credential=AzureCliCredential())

Contribution Checklist

@dmytrostruk dmytrostruk self-assigned this Aug 19, 2025
@moonbox3 moonbox3 added python Pull requests for the Python Semantic Kernel documentation labels Aug 19, 2025
@moonbox3
Copy link
Collaborator

moonbox3 commented Aug 19, 2025

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
kernel.py2285874%148, 159, 163, 313–314, 316, 398, 404–405, 409–410, 463–467, 469–470, 483–492, 494, 496–497, 499–519, 521–526
agents/azure_ai
   azure_ai_agent.py36218050%99, 101–104, 106–108, 110–115, 117, 119, 121–123, 125, 142, 144–147, 149–154, 156, 161–162, 167–170, 175–179, 181–184, 186–192, 197, 199–202, 204–206, 208–211, 213, 215, 225–226, 228–231, 233–234, 239, 241–247, 249, 282, 293–294, 299–300, 303, 308–313, 320–321, 323, 328–329, 340–346, 398, 400, 406, 417, 420, 422, 424, 426, 460, 491–493, 495, 497–498, 500–503, 506–508, 510–511, 514, 517–526, 528, 537–538, 541–543, 545–546, 556–557, 559, 577, 579, 582, 584–585, 587–588, 590, 599–600, 602, 604–607, 610, 612, 615–617, 621, 690, 796, 900, 973
agents/open_ai
   azure_assistant_agent.py902572%35, 108, 112, 180–181, 191–192, 194, 201, 204–205, 209–214, 216–217, 219–220, 222, 252, 272, 282
   azure_responses_agent.py926133%39, 94–95, 105–106, 108, 115, 118–119, 123–128, 130–131, 133–134, 136, 146, 187–188, 198–199, 201, 208, 211–212, 216–221, 223–224, 226–227, 229, 248, 250, 253, 255–256, 258–259, 261, 271–272, 274, 276–279, 282, 284, 287–289, 293
connectors
   azure_cosmos_db.py40316758%182, 199, 205–207, 317, 319, 394, 398, 414–417, 419–422, 424–425, 438–441, 444–446, 452–453, 455, 462–464, 468–470, 493–495, 501–503, 509–510, 512, 517, 534, 609, 626, 629–630, 638, 648–652, 709, 712–713, 750, 752, 765–766, 770–772, 783–786, 789–790, 792–793, 798–802, 805–808, 810–815, 817–818, 825–830, 849–851, 853–856, 864, 871–876, 878–892, 894–905, 908, 910–911, 914–915, 918, 920–925, 931, 935, 959, 987–988, 992–997, 1089–1094
   sql_server.py5079082%152, 258, 352–354, 374, 393, 404, 406, 429, 475–478, 494, 506–509, 531, 533, 577–583, 589–590, 592–593, 597–611, 614–619, 622–626, 631, 637–638, 641, 647–648, 650–653, 796, 815–817, 823, 829, 834, 839–842, 848, 882, 924, 931–933, 1099–1100, 1102, 1104, 1125
connectors/ai/azure_ai_inference/services
   azure_ai_inference_base.py46393%98–99, 101
connectors/ai/open_ai/services
   azure_audio_to_text.py240100% 
   azure_chat_completion.py810100% 
   azure_config_base.py59493%82, 98, 100, 112
   azure_realtime.py612952%104–105, 115–119, 140, 212–213, 223–230, 250, 255, 259–260, 267, 278–283
   azure_text_completion.py250100% 
   azure_text_embedding.py270100% 
   azure_text_to_audio.py240100% 
   azure_text_to_image.py240100% 
connectors/ai/open_ai/settings
   azure_open_ai_settings.py30680%130–135
core_plugins/sessions_python_tool
   sessions_python_plugin.py135894%71, 86, 88–89, 91, 93, 95, 103
   sessions_python_settings.py42685%88–93
utils/authentication
   entra_id_authentication.py14842%26–27, 31–35, 37
TOTAL26898464682% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
3682 22 💤 0 ❌ 0 🔥 1m 37s ⏱️

@dmytrostruk dmytrostruk added the PR: breaking change Pull requests that introduce breaking changes label Aug 19, 2025
@dmytrostruk dmytrostruk marked this pull request as ready for review August 19, 2025 03:55
@dmytrostruk dmytrostruk requested a review from a team as a code owner August 19, 2025 03:55
@dmytrostruk dmytrostruk marked this pull request as draft August 20, 2025 19:36
@dmytrostruk dmytrostruk marked this pull request as ready for review August 22, 2025 18:05
@dmytrostruk dmytrostruk added this pull request to the merge queue Aug 25, 2025
@dmytrostruk dmytrostruk removed this pull request from the merge queue due to a manual request Aug 25, 2025
@dmytrostruk dmytrostruk enabled auto-merge August 25, 2025 16:46
@dmytrostruk dmytrostruk added this pull request to the merge queue Aug 25, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 25, 2025
@dmytrostruk dmytrostruk enabled auto-merge August 25, 2025 18:07
@dmytrostruk dmytrostruk added this pull request to the merge queue Aug 25, 2025
Merged via the queue into microsoft:main with commit 2a47ba9 Aug 25, 2025
28 checks passed
@dmytrostruk dmytrostruk deleted the python-default-token-credential branch August 25, 2025 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation PR: breaking change Pull requests that introduce breaking changes python Pull requests for the Python Semantic Kernel
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants