azure-cli-core 2.85.0__tar.gz → 2.87.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/HISTORY.rst +13 -0
  2. {azure_cli_core-2.85.0/azure_cli_core.egg-info → azure_cli_core-2.87.0}/PKG-INFO +5 -5
  3. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/__init__.py +1 -1
  4. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/_help.py +1 -11
  5. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/_profile.py +75 -13
  6. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/aaz/__init__.py +2 -1
  7. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/aaz/_command.py +175 -0
  8. azure_cli_core-2.87.0/azure/cli/core/auth/agentic_session.py +67 -0
  9. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/auth/msal_credentials.py +21 -0
  10. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/azclierror.py +11 -8
  11. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/azlogging.py +30 -1
  12. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/breaking_change.py +2 -2
  13. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/cloud.py +2 -5
  14. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/commandIndex.latest.json +1 -4
  15. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/command_recommender.py +4 -205
  16. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/helpIndex.latest.json +2 -2
  17. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/parser.py +2 -2
  18. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/profiles/_shared.py +1 -1
  19. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/style.py +0 -2
  20. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/telemetry.py +7 -0
  21. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/util.py +1 -2
  22. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0/azure_cli_core.egg-info}/PKG-INFO +5 -5
  23. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure_cli_core.egg-info/SOURCES.txt +1 -0
  24. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure_cli_core.egg-info/requires.txt +4 -4
  25. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/setup.py +5 -5
  26. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/LICENSE.txt +0 -0
  27. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/MANIFEST.in +0 -0
  28. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/README.rst +0 -0
  29. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/__init__.py +0 -0
  30. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/__init__.py +0 -0
  31. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/_breaking_change.py +0 -0
  32. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/_completers.py +0 -0
  33. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/_config.py +0 -0
  34. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/_debug.py +0 -0
  35. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/_environment.py +0 -0
  36. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/_help_loaders.py +0 -0
  37. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/_output.py +0 -0
  38. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/_session.py +0 -0
  39. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/aaz/_arg.py +0 -0
  40. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/aaz/_arg_action.py +0 -0
  41. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/aaz/_arg_browser.py +0 -0
  42. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/aaz/_arg_fmt.py +0 -0
  43. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/aaz/_base.py +0 -0
  44. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/aaz/_client.py +0 -0
  45. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/aaz/_command_ctx.py +0 -0
  46. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/aaz/_content_builder.py +0 -0
  47. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/aaz/_error_format.py +0 -0
  48. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/aaz/_field_type.py +0 -0
  49. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/aaz/_field_value.py +0 -0
  50. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/aaz/_help.py +0 -0
  51. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/aaz/_http_policy.py +0 -0
  52. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/aaz/_operation.py +0 -0
  53. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/aaz/_paging.py +0 -0
  54. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/aaz/_poller.py +0 -0
  55. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/aaz/_prompt.py +0 -0
  56. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/aaz/_selector.py +0 -0
  57. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/aaz/_utils.py +0 -0
  58. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/aaz/exceptions.py +0 -0
  59. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/aaz/utils.py +0 -0
  60. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/api.py +0 -0
  61. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/auth/__init__.py +0 -0
  62. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/auth/binary_cache.py +0 -0
  63. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/auth/constants.py +0 -0
  64. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/auth/credential_adaptor.py +0 -0
  65. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/auth/identity.py +0 -0
  66. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/auth/landing_pages/error.html +0 -0
  67. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/auth/landing_pages/success.html +0 -0
  68. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/auth/persistence.py +0 -0
  69. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/auth/util.py +0 -0
  70. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/commands/__init__.py +0 -0
  71. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/commands/arm.py +0 -0
  72. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/commands/client_factory.py +0 -0
  73. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/commands/command_operation.py +0 -0
  74. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/commands/constants.py +0 -0
  75. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/commands/events.py +0 -0
  76. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/commands/parameters.py +0 -0
  77. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/commands/progress.py +0 -0
  78. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/commands/sensitive.py +0 -0
  79. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/commands/template_create.py +0 -0
  80. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/commands/transform.py +0 -0
  81. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/commands/validators.py +0 -0
  82. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/credential_helper.py +0 -0
  83. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/decorators.py +0 -0
  84. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/extension/__init__.py +0 -0
  85. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/extension/_homebrew_patch.py +0 -0
  86. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/extension/_index.py +0 -0
  87. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/extension/_resolve.py +0 -0
  88. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/extension/dynamic_install.py +0 -0
  89. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/extension/operations.py +0 -0
  90. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/file_util.py +0 -0
  91. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/intercept_survey.py +0 -0
  92. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/keys.py +0 -0
  93. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/local_context.py +0 -0
  94. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/mock.py +0 -0
  95. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/profiles/__init__.py +0 -0
  96. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/sdk/__init__.py +0 -0
  97. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure/cli/core/sdk/policies.py +0 -0
  98. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure_cli_core.egg-info/dependency_links.txt +0 -0
  99. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure_cli_core.egg-info/not-zip-safe +0 -0
  100. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/azure_cli_core.egg-info/top_level.txt +0 -0
  101. {azure_cli_core-2.85.0 → azure_cli_core-2.87.0}/setup.cfg +0 -0
@@ -3,6 +3,19 @@
3
3
  Release History
4
4
  ===============
5
5
 
6
+ 2.87.0
7
+ ++++++
8
+ * Resolve CVE-2026-44431 (#33351)
9
+ * Resolve CVE-2026-44432 (#33351)
10
+ * `az login`: Support Entra agentic session differentiation for Copilot agent requests (#33309)
11
+ * Resolve CVE-2026-45409 (#33401)
12
+
13
+ 2.86.0
14
+ ++++++
15
+ * Resolve CVE-2025-15467 (#33201)
16
+ * Resolve CVE-2025-69419 (#33201)
17
+ * Resolve CVE-2026-39892 (#33154)
18
+
6
19
  2.85.0
7
20
  ++++++
8
21
  * Resolve CVE-2026-26007 (#32879)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: azure-cli-core
3
- Version: 2.85.0
3
+ Version: 2.87.0
4
4
  Summary: Microsoft Azure Command-Line Tools Core Module
5
5
  Home-page: https://github.com/Azure/azure-cli
6
6
  Author: Microsoft Corporation
@@ -26,11 +26,11 @@ Requires-Dist: cryptography
26
26
  Requires-Dist: distro; sys_platform == "linux"
27
27
  Requires-Dist: humanfriendly~=10.0
28
28
  Requires-Dist: jmespath
29
- Requires-Dist: knack~=0.11.0
29
+ Requires-Dist: knack~=0.14.0
30
30
  Requires-Dist: microsoft-security-utilities-secret-masker~=1.0.0b4
31
- Requires-Dist: msal-extensions==1.2.0
32
- Requires-Dist: msal[broker]==1.35.1; sys_platform == "win32"
33
- Requires-Dist: msal==1.35.1; sys_platform != "win32"
31
+ Requires-Dist: msal-extensions==1.3.1
32
+ Requires-Dist: msal[broker]==1.36.0; sys_platform == "win32"
33
+ Requires-Dist: msal==1.36.0; sys_platform != "win32"
34
34
  Requires-Dist: packaging>=20.9
35
35
  Requires-Dist: pkginfo>=1.5.0.1
36
36
  Requires-Dist: psutil>=5.9; sys_platform != "cygwin"
@@ -4,7 +4,7 @@
4
4
  # --------------------------------------------------------------------------------------------
5
5
  # pylint: disable=line-too-long
6
6
 
7
- __version__ = "2.85.0"
7
+ __version__ = "2.87.0"
8
8
 
9
9
  import os
10
10
  import sys
@@ -129,7 +129,6 @@ class CLIPrintMixin(CLIHelp):
129
129
  def _print_detailed_help(self, cli_name, help_file):
130
130
  CLIPrintMixin._print_extensions_msg(help_file)
131
131
  super()._print_detailed_help(cli_name, help_file)
132
- self._print_az_find_message(help_file.command)
133
132
 
134
133
  @staticmethod
135
134
  def _get_choices_defaults_sources_str(p):
@@ -154,12 +153,6 @@ class CLIPrintMixin(CLIHelp):
154
153
  _print_indent('{0}'.format(e.command), indent)
155
154
  print('')
156
155
 
157
- @staticmethod
158
- def _print_az_find_message(command):
159
- indent = 0
160
- message = 'To search AI knowledge base for examples, use: az find "az {}"'.format(command)
161
- _print_indent(message + '\n', indent)
162
-
163
156
  @staticmethod
164
157
  def _process_value_sources(p):
165
158
  commands, strings, urls = [], [], []
@@ -401,10 +394,7 @@ class AzCliHelp(CLIPrintMixin, CLIHelp):
401
394
 
402
395
  self._print_cached_help_section(groups_items, "Subgroups:", max_line_len)
403
396
  self._print_cached_help_section(commands_items, "Commands:", max_line_len)
404
-
405
- # Use same az find message as non-cached path
406
- print() # Blank line before the message
407
- self._print_az_find_message('')
397
+ print()
408
398
 
409
399
  from azure.cli.core.util import show_updates_available
410
400
  show_updates_available(new_line_after=True)
@@ -152,7 +152,9 @@ class Profile:
152
152
  allow_no_subscriptions=False,
153
153
  use_cert_sn_issuer=None,
154
154
  show_progress=False,
155
- claims_challenge=None):
155
+ claims_challenge=None,
156
+ skip_subscription_discovery=False,
157
+ subscription=None):
156
158
  """
157
159
  For service principal, `password` is a dict returned by ServicePrincipalAuth.build_credential
158
160
  """
@@ -198,15 +200,31 @@ class Profile:
198
200
  else:
199
201
  credential = identity.get_service_principal_credential(username)
200
202
 
201
- if tenant:
203
+ is_bare_mode = skip_subscription_discovery and not subscription
204
+
205
+ if skip_subscription_discovery and subscription:
206
+ # Fast path: fetch only the specified subscription (1 API call)
207
+ subscriptions = subscription_finder.find_specific_subscriptions(
208
+ tenant, credential, [subscription])
209
+ elif is_bare_mode:
210
+ # Bare mode: no ARM subscription calls. Tenant-level account will be created below
211
+ subscriptions = []
212
+ subscription_finder.tenants.append(tenant)
213
+ elif tenant:
202
214
  subscriptions = subscription_finder.find_using_specific_tenant(tenant, credential)
203
215
  else:
204
216
  subscriptions = subscription_finder.find_using_common_tenant(username, credential)
205
217
 
206
218
  if not subscriptions and not allow_no_subscriptions:
207
- raise CLIError("No subscriptions found for {}.".format(username))
208
-
209
- if allow_no_subscriptions:
219
+ if skip_subscription_discovery and subscription:
220
+ raise CLIError(
221
+ "The subscription '{}' could not be retrieved for '{}'. "
222
+ "Ensure the subscription exists and that you have access to it.".format(
223
+ subscription, username))
224
+ if not is_bare_mode:
225
+ raise CLIError("No subscriptions found for {}.".format(username))
226
+
227
+ if allow_no_subscriptions or is_bare_mode:
210
228
  t_list = [s.tenant_id for s in subscriptions]
211
229
  bare_tenants = [t for t in subscription_finder.tenants if t not in t_list]
212
230
  tenant_accounts = self._build_tenant_level_accounts(bare_tenants)
@@ -216,8 +234,24 @@ class Profile:
216
234
 
217
235
  consolidated = self._normalize_properties(username, subscriptions,
218
236
  is_service_principal, bool(use_cert_sn_issuer))
237
+ self._set_subscriptions(consolidated, preferred_subscription=subscription)
238
+
239
+ if subscription:
240
+ matches = [s for s in consolidated
241
+ if s[_SUBSCRIPTION_ID].lower() == subscription.lower() or
242
+ s.get(_SUBSCRIPTION_NAME, '').lower() == subscription.lower()]
243
+ if matches:
244
+ return deepcopy(matches)
245
+ if skip_subscription_discovery:
246
+ # --skip-subscription-discovery + --subscription S, but S is inaccessible.
247
+ # without --allow-no-subscriptions → already errored above
248
+ # with --allow-no-subscriptions → tenant-level account only (we reach here)
249
+ logger.warning("Subscription '%s' not found. Profile has tenant-level account only.",
250
+ subscription)
251
+ else:
252
+ raise CLIError("Subscription '{}' not found. Check the ID or name and try again."
253
+ .format(subscription))
219
254
 
220
- self._set_subscriptions(consolidated)
221
255
  return deepcopy(consolidated)
222
256
 
223
257
  def login_with_managed_identity(self, client_id=None, object_id=None, resource_id=None,
@@ -463,7 +497,8 @@ class Profile:
463
497
  s.state = 'Enabled'
464
498
  return s
465
499
 
466
- def _set_subscriptions(self, new_subscriptions, merge=True, secondary_key_name=None):
500
+ def _set_subscriptions(self, new_subscriptions, merge=True, secondary_key_name=None,
501
+ preferred_subscription=None):
467
502
 
468
503
  def _get_key_name(account, secondary_key_name):
469
504
  return (account[_SUBSCRIPTION_ID] if secondary_key_name is None
@@ -489,17 +524,26 @@ class Profile:
489
524
  dic.update((_get_key_name(x, secondary_key_name), x) for x in new_subscriptions)
490
525
  subscriptions = list(dic.values())
491
526
  if subscriptions:
492
- if active_one:
527
+ new_active_one = None
528
+
529
+ # If a preferred subscription is specified, try to use it as default
530
+ if preferred_subscription:
531
+ preferred_lower = preferred_subscription.lower()
532
+ new_active_one = next(
533
+ (x for x in new_subscriptions
534
+ if x[_SUBSCRIPTION_ID].lower() == preferred_lower or
535
+ x.get(_SUBSCRIPTION_NAME, '').lower() == preferred_lower), None)
536
+
537
+ # Fall back to previously active subscription if still present
538
+ if not new_active_one and active_one:
493
539
  new_active_one = next(
494
540
  (x for x in new_subscriptions if _match_account(x, active_subscription_id, secondary_key_name,
495
541
  active_secondary_key_val)), None)
496
542
 
497
- for s in subscriptions:
498
- s[_IS_DEFAULT_SUBSCRIPTION] = False
543
+ for s in subscriptions:
544
+ s[_IS_DEFAULT_SUBSCRIPTION] = False
499
545
 
500
- if not new_active_one:
501
- new_active_one = Profile._pick_working_subscription(new_subscriptions)
502
- else:
546
+ if not new_active_one:
503
547
  new_active_one = Profile._pick_working_subscription(new_subscriptions)
504
548
 
505
549
  new_active_one[_IS_DEFAULT_SUBSCRIPTION] = True
@@ -507,6 +551,7 @@ class Profile:
507
551
 
508
552
  set_cloud_subscription(self.cli_ctx, active_cloud.name, default_sub_id)
509
553
  self._storage[_SUBSCRIPTIONS] = subscriptions
554
+ return subscriptions
510
555
 
511
556
  @staticmethod
512
557
  def _pick_working_subscription(subscriptions):
@@ -856,6 +901,23 @@ class SubscriptionFinder:
856
901
  self.tenants.append(tenant)
857
902
  return all_subscriptions
858
903
 
904
+ def find_specific_subscriptions(self, tenant, credential, subscription_ids):
905
+ """Fetch specific subscriptions by ID using GET /subscriptions/{id}
906
+ instead of listing all subscriptions.
907
+ https://learn.microsoft.com/en-us/rest/api/resources/subscriptions/get
908
+ """
909
+ client = self._create_subscription_client(credential)
910
+ all_subscriptions = []
911
+ for sub_id in subscription_ids:
912
+ try:
913
+ s = client.subscriptions.get(sub_id)
914
+ _attach_token_tenant(s, tenant)
915
+ all_subscriptions.append(s)
916
+ except Exception as ex: # pylint: disable=broad-except
917
+ logger.warning("Failed to retrieve subscription %s: %s", sub_id, ex)
918
+ self.tenants.append(tenant)
919
+ return all_subscriptions
920
+
859
921
  def _create_subscription_client(self, credential):
860
922
  from azure.cli.core.profiles import ResourceType, get_api_version
861
923
  from azure.cli.core.profiles._shared import get_client_class
@@ -21,7 +21,8 @@ from ._arg_fmt import AAZStrArgFormat, AAZIntArgFormat, AAZFloatArgFormat, AAZBo
21
21
  AAZPaginationTokenArgFormat
22
22
  from ._base import has_value, AAZValuePatch, AAZUndefined
23
23
  from ._command import AAZCommand, AAZWaitCommand, AAZCommandGroup, \
24
- register_callback, register_command, register_command_group, load_aaz_command_table, link_helper
24
+ register_callback, register_command, register_command_group, load_aaz_command_table, \
25
+ load_aaz_command_table_args_guided, link_helper
25
26
  from ._field_type import AAZIntType, AAZFloatType, AAZStrType, AAZBoolType, AAZDictType, AAZFreeFormDictType, \
26
27
  AAZListType, AAZObjectType, AAZIdentityObjectType, AAZAnyType
27
28
  from ._operation import AAZHttpOperation, AAZJsonInstanceUpdateOperation, AAZGenericInstanceUpdateOperation, \
@@ -387,6 +387,181 @@ def register_command(
387
387
  AAZ_PACKAGE_FULL_LOAD_ENV_NAME = 'AZURE_AAZ_FULL_LOAD'
388
388
 
389
389
 
390
+ def load_aaz_command_table_args_guided(loader, aaz_pkg_name, args):
391
+ """Args-guided AAZ command tree loader.
392
+
393
+ Instead of importing the entire AAZ package tree (all __init__.py files which eagerly
394
+ import all command classes), this function navigates only to the relevant subtree based
395
+ on CLI args. For example, ``az monitor log-analytics workspace create --help`` only loads
396
+ the ``workspace`` sub-package and the ``_create`` module, skipping all other commands.
397
+
398
+ This requires that AAZ ``__init__.py`` files do NOT contain wildcard imports
399
+ (``from ._create import *`` etc.) -- they should be empty (just the license header).
400
+ """
401
+ profile_pkg = _get_profile_pkg(aaz_pkg_name, loader.cli_ctx.cloud)
402
+
403
+ command_table = {}
404
+ command_group_table = {}
405
+ if args is None or os.environ.get(AAZ_PACKAGE_FULL_LOAD_ENV_NAME, 'False').lower() == 'true':
406
+ effective_args = None # fully load
407
+ else:
408
+ effective_args = list(args)
409
+ if profile_pkg is not None:
410
+ _load_aaz_by_pkg(loader, profile_pkg, effective_args,
411
+ command_table, command_group_table)
412
+
413
+ for group_name, command_group in command_group_table.items():
414
+ loader.command_group_table[group_name] = command_group
415
+ for command_name, command in command_table.items():
416
+ loader.command_table[command_name] = command
417
+ return command_table, command_group_table
418
+
419
+
420
+ def _try_import_module(relative_name, package):
421
+ """Try to import a module by relative name, return None on failure."""
422
+ try:
423
+ return importlib.import_module(relative_name, package)
424
+ except ModuleNotFoundError as ex:
425
+ # Only treat "module not found" for the requested module as a benign miss.
426
+ target_mod_name = f"{package}.{relative_name.lstrip('.')}"
427
+ if ex.name == target_mod_name:
428
+ return None
429
+ # Different module is missing; propagate so the real error surfaces.
430
+ raise
431
+ except ImportError:
432
+ logger.error("Error importing module %r from package %r", relative_name, package)
433
+ raise
434
+
435
+
436
+ def _register_from_module(loader, mod, command_table, command_group_table):
437
+ """Scan a module's namespace for AAZCommand/AAZCommandGroup classes and register them."""
438
+ for value in mod.__dict__.values():
439
+ if not isinstance(value, type):
440
+ continue
441
+ if value.__module__ != mod.__name__: # skip imported classes
442
+ continue
443
+ if issubclass(value, AAZCommandGroup) and value.AZ_NAME:
444
+ command_group_table[value.AZ_NAME] = value(cli_ctx=loader.cli_ctx)
445
+ elif issubclass(value, AAZCommand) and value.AZ_NAME:
446
+ command_table[value.AZ_NAME] = value(loader=loader)
447
+
448
+
449
+ def _get_pkg_children(pkg):
450
+ """List child entries of a package using pkgutil.
451
+
452
+ Returns two sets: (file_stems, subdir_names).
453
+ - file_stems: module-like stems, e.g. {'_create', '_list', '__cmd_group'}
454
+ - subdir_names: sub-package directory names, e.g. {'namespace', 'eventhub'}
455
+ """
456
+ import pkgutil
457
+ file_stems = set()
458
+ subdir_names = set()
459
+
460
+ pkg_path = getattr(pkg, '__path__', None)
461
+ if not pkg_path:
462
+ return file_stems, subdir_names
463
+
464
+ for _importer, name, ispkg in pkgutil.iter_modules(pkg_path):
465
+ if ispkg:
466
+ if not name.startswith('_'):
467
+ subdir_names.add(name)
468
+ else:
469
+ file_stems.add(name)
470
+
471
+ return file_stems, subdir_names
472
+
473
+
474
+ def _load_aaz_by_pkg(loader, pkg, args, command_table, command_group_table):
475
+ """Recursively navigate the AAZ package tree guided by CLI args.
476
+
477
+ - args is None -> full recursive load of all commands under this package.
478
+ - args is empty list -> args exhausted; load current level's commands and sub-group headers.
479
+ - args has items -> try to match first arg as a command module or sub-package,
480
+ recurse with remaining args on match.
481
+ - no match on first arg -> load current level's commands and sub-group headers.
482
+ """
483
+ base_module = pkg.__name__
484
+ file_stems, subdir_names = _get_pkg_children(pkg)
485
+
486
+ if args is not None and args and not args[0].startswith('-'):
487
+ first_arg = args[0].lower().replace('-', '_')
488
+
489
+ # First arg matches a command module (e.g. "create" -> "_create")
490
+ if f"_{first_arg}" in file_stems:
491
+ mod = _try_import_module(f"._{first_arg}", base_module)
492
+ if mod:
493
+ _register_from_module(loader, mod, command_table, command_group_table)
494
+ return
495
+
496
+ # First arg matches a sub-package (command group)
497
+ if first_arg in subdir_names:
498
+ sub_module = f"{base_module}.{first_arg}"
499
+ mod = _try_import_module('.__cmd_group', sub_module)
500
+ if mod:
501
+ _register_from_module(loader, mod, command_table, command_group_table)
502
+ sub_pkg = _try_import_module(f'.{first_arg}', base_module)
503
+ if sub_pkg:
504
+ _load_aaz_by_pkg(loader, sub_pkg, args[1:], command_table, command_group_table)
505
+ return
506
+
507
+ # Load __cmd_group + all command modules at this level
508
+ mod = _try_import_module('.__cmd_group', base_module)
509
+ if mod:
510
+ _register_from_module(loader, mod, command_table, command_group_table)
511
+
512
+ for stem in file_stems:
513
+ if stem.startswith('_') and not stem.startswith('__'):
514
+ mod = _try_import_module(f'.{stem}', base_module)
515
+ if mod:
516
+ _register_from_module(loader, mod, command_table, command_group_table)
517
+
518
+ for subdir in subdir_names:
519
+ sub_module = f"{base_module}.{subdir}"
520
+ if args is None:
521
+ # Full load -> recurse into every sub-package
522
+ sub_pkg = _try_import_module(f'.{subdir}', base_module)
523
+ if sub_pkg:
524
+ _load_aaz_by_pkg(loader, sub_pkg, None, command_table, command_group_table)
525
+ else:
526
+ # Args exhausted / not matched -> load sub-group header and the first
527
+ # command so the group is non-empty and the parser creates a subparser
528
+ # for it (required for help output).
529
+ # TODO: After optimized loading is applied to the whole CLI, revisit
530
+ # this and consider a lighter approach (e.g. parser-level fix) to
531
+ # avoid importing one command per trimmed sub-group.
532
+ mod = _try_import_module('.__cmd_group', sub_module)
533
+ if mod:
534
+ _register_from_module(loader, mod, command_table, command_group_table)
535
+ sub_pkg = _try_import_module(f'.{subdir}', base_module)
536
+ if sub_pkg:
537
+ _load_first_command(loader, sub_pkg, command_table)
538
+
539
+
540
+ def _load_first_command(loader, pkg, command_table):
541
+ """Load the first available command module from a package.
542
+
543
+ This ensures the command group is non-empty so the parser creates a subparser
544
+ for it, which is required for it to appear in help output.
545
+ """
546
+ file_stems, subdir_names = _get_pkg_children(pkg)
547
+ base_module = pkg.__name__
548
+
549
+ # Try to load a command module at this level first
550
+ for stem in sorted(file_stems):
551
+ if stem.startswith('_') and not stem.startswith('__'):
552
+ mod = _try_import_module(f'.{stem}', base_module)
553
+ if mod:
554
+ _register_from_module(loader, mod, command_table, {})
555
+ return
556
+
557
+ # No command at this level, recurse into the first sub-package
558
+ for subdir in sorted(subdir_names):
559
+ sub_pkg = _try_import_module(f'.{subdir}', base_module)
560
+ if sub_pkg:
561
+ _load_first_command(loader, sub_pkg, command_table)
562
+ return
563
+
564
+
390
565
  def load_aaz_command_table(loader, aaz_pkg_name, args):
391
566
  """ This function is used in AzCommandsLoader.load_command_table.
392
567
  It will load commands in module's aaz package.
@@ -0,0 +1,67 @@
1
+ # --------------------------------------------------------------------------------------------
2
+ # Copyright (c) Microsoft Corporation. All rights reserved.
3
+ # Licensed under the MIT License. See License.txt in the project root for license information.
4
+ # --------------------------------------------------------------------------------------------
5
+
6
+ """
7
+ Support for Entra Agentic Sessions.
8
+
9
+ When CLI runs inside an agent context (e.g., Copilot, Azure MCP), the orchestrator sets the
10
+ COPILOT_AGENT_SESSION_ID environment variable. CLI reads it and passes it to MSAL as both:
11
+ - A query parameter (`client_session`) so ESTS can identify the agentic session
12
+ - A claims challenge so ESTS embeds an agentic marker claim in the token (and MSAL bypasses
13
+ the access token cache to ensure a fresh, agent-tagged token is always fetched)
14
+
15
+ This enables downstream systems (RBAC, Defender, Purview) to enforce differentiated policies
16
+ for agent-driven vs. human-driven operations.
17
+ """
18
+
19
+ import json
20
+ import os
21
+
22
+ from knack.log import get_logger
23
+
24
+ logger = get_logger(__name__)
25
+
26
+ COPILOT_AGENT_SESSION_ID = "COPILOT_AGENT_SESSION_ID"
27
+
28
+
29
+ def build_agentic_session_params():
30
+ """Read COPILOT_AGENT_SESSION_ID and build the agentic claims challenge.
31
+
32
+ :returns: (session_id, claims_challenge) — both None when env var is not set.
33
+ """
34
+ session_id = os.environ.get(COPILOT_AGENT_SESSION_ID) or None
35
+ if not session_id:
36
+ return None, None
37
+
38
+ logger.debug("Agentic session detected (COPILOT_AGENT_SESSION_ID is set)")
39
+
40
+ claims_challenge = json.dumps({
41
+ "access_token": {
42
+ "xms_cli_sid": {"values": [session_id]}
43
+ }
44
+ })
45
+ return session_id, claims_challenge
46
+
47
+
48
+ def merge_access_token_claims(existing_claims, new_claims):
49
+ """Merge new claims into an existing claims_challenge JSON string.
50
+
51
+ :param existing_claims: Existing claims_challenge JSON string (or None).
52
+ :param new_claims: New claims_challenge JSON string to merge in. Must not be None or empty,
53
+ and must contain a non-empty ``access_token`` object.
54
+ :returns: Merged claims_challenge JSON string.
55
+ :raises ValueError: If ``new_claims`` is None, empty, or does not contain a non-empty
56
+ ``access_token`` object.
57
+ """
58
+ if not new_claims:
59
+ raise ValueError("new_claims must not be None or empty")
60
+ new_access_token = json.loads(new_claims).get("access_token")
61
+ if not new_access_token:
62
+ raise ValueError("new_claims must contain a non-empty access_token")
63
+
64
+ claims_dict = json.loads(existing_claims) if existing_claims else {}
65
+ claims_dict["access_token"] = claims_dict.get("access_token") or {}
66
+ claims_dict["access_token"].update(new_access_token)
67
+ return json.dumps(claims_dict)
@@ -50,6 +50,27 @@ class UserCredential: # pylint: disable=too-few-public-methods
50
50
  logger.debug("UserCredential.acquire_token: scopes=%r, claims_challenge=%r, kwargs=%r",
51
51
  scopes, claims_challenge, kwargs)
52
52
 
53
+ # Apply agentic session parameters for user identity flows
54
+ from .agentic_session import build_agentic_session_params, merge_access_token_claims
55
+ agentic_session_id, agentic_claims = build_agentic_session_params()
56
+ if agentic_session_id:
57
+ # Both paths: client_session in data and params so eSTS can identify the agentic session
58
+ kwargs["data"] = kwargs.get("data") or {}
59
+ kwargs["data"]["client_session"] = agentic_session_id
60
+ kwargs["params"] = kwargs.get("params") or {}
61
+ kwargs["params"]["client_session"] = agentic_session_id
62
+
63
+ if getattr(self._msal_app, '_enable_broker', False):
64
+ # Broker path: claims_challenge flows to MSALRuntime cache key via set_decoded_claims.
65
+ # This causes MSAL to skip its local AT cache and forward claims to the broker,
66
+ # where requestedClaims becomes part of the C++ cache key.
67
+ claims_challenge = merge_access_token_claims(claims_challenge, agentic_claims)
68
+ # Non-broker path: client_session in data flows into ext_cache_key (SHA256 hash),
69
+ # which partitions the MSAL Python token cache. No claims_challenge needed.
70
+
71
+ from azure.cli.core.telemetry import set_agentic_session
72
+ set_agentic_session(True)
73
+
53
74
  if claims_challenge:
54
75
  logger.info('Acquiring new access token silently with claims challenge: %s', claims_challenge)
55
76
  result = self._msal_app.acquire_token_silent_with_error(
@@ -33,8 +33,8 @@ class AzCLIError(CLIError):
33
33
  self.recommendations = []
34
34
  self.set_recommendation(recommendation)
35
35
 
36
- # AI recommendations provided by Aladdin service, with tuple form: (recommendation, description)
37
- self.aladdin_recommendations = []
36
+ # example recommendations with tuple form: (recommendation, description)
37
+ self.example_recommendations = []
38
38
 
39
39
  # exception trace for the error
40
40
  self.exception_trace = None
@@ -50,11 +50,11 @@ class AzCLIError(CLIError):
50
50
  elif isinstance(recommendation, list):
51
51
  self.recommendations.extend(recommendation)
52
52
 
53
- def set_aladdin_recommendation(self, recommendations):
54
- """ Set aladdin recommendations for the error.
53
+ def set_example_recommendation(self, recommendations):
54
+ """ Set example recommendations for the error.
55
55
  One item should be a tuple with the form: (recommendation, description)
56
56
  """
57
- self.aladdin_recommendations.extend(recommendations)
57
+ self.example_recommendations.extend(recommendations)
58
58
 
59
59
  def set_exception_trace(self, exception_trace):
60
60
  self.exception_trace = exception_trace
@@ -80,9 +80,12 @@ class AzCLIError(CLIError):
80
80
  for recommendation in self.recommendations:
81
81
  print(recommendation, file=sys.stderr)
82
82
 
83
- if self.aladdin_recommendations:
84
- print('\nExamples from AI knowledge base:', file=sys.stderr)
85
- for recommendation, description in self.aladdin_recommendations:
83
+ if self.example_recommendations:
84
+ print(file=sys.stderr)
85
+ if len(self.example_recommendations) > 1: # contains help examples
86
+ print("Examples from command's help:", file=sys.stderr)
87
+
88
+ for recommendation, description in self.example_recommendations:
86
89
  print_styled_text(recommendation, file=sys.stderr)
87
90
  print_styled_text(description, file=sys.stderr)
88
91
 
@@ -26,6 +26,7 @@ omitted Warning Debug Critical Debug
26
26
  import os
27
27
  import logging
28
28
  import datetime
29
+ from logging.handlers import RotatingFileHandler
29
30
 
30
31
  from azure.cli.core.commands.events import EVENT_INVOKER_PRE_CMD_TBL_TRUNCATE
31
32
 
@@ -38,6 +39,20 @@ _UNKNOWN_COMMAND = "unknown_command"
38
39
  _CMD_LOG_LINE_PREFIX = "CMD-LOG-LINE-BEGIN"
39
40
 
40
41
 
42
+ class SecureFileHandler(logging.FileHandler):
43
+ """A FileHandler that creates the log file with 600 permissions (owner read/write only)."""
44
+ def _open(self):
45
+ fd = os.open(self.baseFilename, os.O_WRONLY | os.O_CREAT | os.O_APPEND, 0o600)
46
+ return os.fdopen(fd, self.mode, encoding=self.encoding)
47
+
48
+
49
+ class SecureRotatingFileHandler(RotatingFileHandler):
50
+ """A RotatingFileHandler that creates log files with 600 permissions (owner read/write only)."""
51
+ def _open(self):
52
+ fd = os.open(self.baseFilename, os.O_WRONLY | os.O_CREAT | os.O_APPEND, 0o600)
53
+ return os.fdopen(fd, self.mode, encoding=self.encoding)
54
+
55
+
41
56
  class AzCliLogging(CLILogging):
42
57
  COMMAND_METADATA_LOGGER = 'az_command_data_logger'
43
58
 
@@ -58,6 +73,20 @@ class AzCliLogging(CLILogging):
58
73
  # when debug log is shown.
59
74
  logging.getLogger("azure.core.pipeline.policies.http_logging_policy").setLevel(logging.CRITICAL)
60
75
 
76
+ def _init_logfile_handlers(self, root_logger, cli_loggers):
77
+ # Override knack's CLILogging._init_logfile_handlers() (called by CLILogging.configure())
78
+ # to use SecureRotatingFileHandler, ensuring log files are created with 0o600 permissions.
79
+ ensure_dir(self.log_dir)
80
+ log_file_path = os.path.join(self.log_dir, self.logfile_name)
81
+ logfile_handler = SecureRotatingFileHandler(log_file_path, maxBytes=10 * 1024 * 1024, backupCount=5,
82
+ encoding=LOG_FILE_ENCODING)
83
+ lfmt = logging.Formatter('%(process)d : %(asctime)s : %(levelname)s : %(name)s : %(message)s')
84
+ logfile_handler.setFormatter(lfmt)
85
+ logfile_handler.setLevel(logging.DEBUG)
86
+ root_logger.addHandler(logfile_handler)
87
+ for cli_logger in cli_loggers:
88
+ cli_logger.addHandler(logfile_handler)
89
+
61
90
  def get_command_log_dir(self):
62
91
  return self.command_log_dir
63
92
 
@@ -112,7 +141,7 @@ class AzCliLogging(CLILogging):
112
141
  log_file_path = os.path.join(self.command_log_dir, log_name)
113
142
  get_logger(__name__).debug("metadata file logging enabled - writing logs to '%s'.", log_file_path)
114
143
 
115
- logfile_handler = logging.FileHandler(log_file_path, encoding=LOG_FILE_ENCODING)
144
+ logfile_handler = SecureFileHandler(log_file_path, encoding=LOG_FILE_ENCODING)
116
145
 
117
146
  lfmt = logging.Formatter(_CMD_LOG_LINE_PREFIX + ' %(process)d | %(asctime)s | %(levelname)s | %(name)s | %(message)s') # pylint: disable=line-too-long
118
147
  logfile_handler.setFormatter(lfmt)
@@ -15,8 +15,8 @@ from knack.util import StatusTag, color_map
15
15
 
16
16
  logger = get_logger()
17
17
 
18
- NEXT_BREAKING_CHANGE_RELEASE = '2.86.0'
19
- NEXT_BREAKING_CHANGE_DATE = 'May 2026'
18
+ NEXT_BREAKING_CHANGE_RELEASE = '2.92.0'
19
+ NEXT_BREAKING_CHANGE_DATE = 'Nov 2026'
20
20
  DEFAULT_BREAKING_CHANGE_TAG = '[Breaking Change]'
21
21
 
22
22
 
@@ -23,9 +23,6 @@ CLOUD_CONFIG_FILE = os.path.join(GLOBAL_CONFIG_DIR, 'clouds.config')
23
23
  # Add names of clouds that don't allow telemetry data collection here such as some air-gapped clouds.
24
24
  CLOUDS_FORBIDDING_TELEMETRY = ['USSec', 'USNat']
25
25
 
26
- # Add names of clouds that don't allow Aladdin requests for command recommendations here
27
- CLOUDS_FORBIDDING_ALADDIN_REQUEST = ['USSec', 'USNat']
28
-
29
26
 
30
27
  class CloudNotRegisteredException(Exception):
31
28
  def __init__(self, cloud_name):
@@ -501,11 +498,11 @@ AZURE_BLEU_CLOUD = Cloud(
501
498
  sql_management='https://management.database.sovcloud-api.fr:8443/',
502
499
  batch_resource_id='https://batch.sovcloud-api.fr/',
503
500
  gallery='https://gallery.sovcloud-api.fr/',
504
- active_directory='https://login.sovcloud-api.fr',
501
+ active_directory='https://login.sovcloud-identity.fr',
505
502
  active_directory_resource_id='https://management.sovcloud-api.fr/',
506
503
  active_directory_graph_resource_id='https://graph.svc.sovcloud.fr/',
507
504
  microsoft_graph_resource_id='https://graph.svc.sovcloud.fr',
508
- vm_image_alias_doc='https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/arm-compute/quickstart-templates/aliases.json',
505
+ vm_image_alias_doc='https://azcliprod.blob.core.windows.net/cli/vm/aliases_master.json',
509
506
  media_resource_id='https://rest.media.sovcloud-api.fr',
510
507
  ossrdbms_resource_id='https://ossrdbms-aad.database.sovcloud-api.fr',
511
508
  portal='https://portal.sovcloud-azure.fr'),