From 99dd25ee3b0d047983f0530688e0cdea44651bcd Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 12 May 2026 05:04:21 +0000 Subject: [PATCH 1/5] Initial plan From 406c294f53c8950e89a9d5be7e8d0ce8a0b16fd7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 12 May 2026 05:08:57 +0000 Subject: [PATCH 2/5] Clarify provider registration subscription scope Agent-Logs-Url: https://github.com/Azure/azure-cli/sessions/3bf1023e-52e6-4455-befe-781c485502ce Co-authored-by: a0x1ab <59631311+a0x1ab@users.noreply.github.com> --- .../cli/command_modules/resource/_help.py | 5 ++++ .../cli/command_modules/resource/custom.py | 12 +++++--- .../tests/latest/test_resource_custom.py | 29 +++++++++++++++++++ 3 files changed, 42 insertions(+), 4 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/resource/_help.py b/src/azure-cli/azure/cli/command_modules/resource/_help.py index 524c4a48210..738682c62bc 100644 --- a/src/azure-cli/azure/cli/command_modules/resource/_help.py +++ b/src/azure-cli/azure/cli/command_modules/resource/_help.py @@ -1747,11 +1747,16 @@ helps['provider register'] = """ type: command short-summary: Register a provider. +long-summary: By default, this command registers the provider in the current default subscription. Use + `--subscription` or run `az account set` first when you need to target a different subscription. examples: - name: Register a provider. (autogenerated) text: | az provider register --namespace 'Microsoft.PolicyInsights' crafted: true + - name: Register a provider for a specific subscription. + text: | + az provider register --namespace Microsoft.CognitiveServices --subscription 00000000-0000-0000-0000-000000000000 - name: Register a provider from RPaaS. text: | az provider register -n 'Microsoft.Confluent' --accept-terms diff --git a/src/azure-cli/azure/cli/command_modules/resource/custom.py b/src/azure-cli/azure/cli/command_modules/resource/custom.py index 67bfae06581..35155bb3822 100644 --- a/src/azure-cli/azure/cli/command_modules/resource/custom.py +++ b/src/azure-cli/azure/cli/command_modules/resource/custom.py @@ -3459,14 +3459,18 @@ def list_features(client, resource_provider_namespace=None): def register_feature(client, resource_provider_namespace, feature_name): - logger.warning("Once the feature '%s' is registered, invoking 'az provider register -n %s' is required " - "to get the change propagated", feature_name, resource_provider_namespace) + logger.warning("Once the feature '%s' is registered, invoke 'az provider register -n %s' in the current " + "default subscription to get the change propagated. Use '--subscription' or run " + "'az account set' first if you need to target a different subscription.", + feature_name, resource_provider_namespace) return client.register(resource_provider_namespace, feature_name) def unregister_feature(client, resource_provider_namespace, feature_name): - logger.warning("Once the feature '%s' is unregistered, invoking 'az provider register -n %s' is required " - "to get the change propagated", feature_name, resource_provider_namespace) + logger.warning("Once the feature '%s' is unregistered, invoke 'az provider register -n %s' in the current " + "default subscription to get the change propagated. Use '--subscription' or run " + "'az account set' first if you need to target a different subscription.", + feature_name, resource_provider_namespace) return client.unregister(resource_provider_namespace, feature_name) diff --git a/src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_resource_custom.py b/src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_resource_custom.py index 29b893ce80b..5ef429c6d52 100644 --- a/src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_resource_custom.py +++ b/src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_resource_custom.py @@ -31,7 +31,10 @@ publish_bicep_file, _process_template_file, _prepare_deployment_properties_unmodified, + register_feature, + unregister_feature, ) +from azure.cli.command_modules.resource._help import helps from azure.cli.command_modules.resource._bicep import (run_bicep_command) @@ -252,6 +255,32 @@ def prompt_function(x): with self.assertRaisesRegex(CLIError, "Missing input parameters: missing"): _get_missing_parameters(parameters, template, prompt_function) + @mock.patch('azure.cli.command_modules.resource.custom.logger.warning') + def test_feature_registration_warning_mentions_subscription_scope(self, logger_warning): + for method_name, operation in [('register', register_feature), ('unregister', unregister_feature)]: + with self.subTest(method_name=method_name): + client = mock.Mock() + expected = object() + getattr(client, method_name).return_value = expected + + result = operation(client, 'Microsoft.CognitiveServices', 'OpenAI.BlockedTools.web_search') + + self.assertIs(result, expected) + getattr(client, method_name).assert_called_once_with( + 'Microsoft.CognitiveServices', 'OpenAI.BlockedTools.web_search') + + self.assertEqual(logger_warning.call_count, 2) + warning_message = logger_warning.call_args_list[0].args[0] + self.assertIn('current default subscription', warning_message) + self.assertIn('--subscription', warning_message) + self.assertIn('az account set', warning_message) + + def test_provider_register_help_mentions_subscription_scope(self): + help_text = helps['provider register'] + self.assertIn('current default subscription', help_text) + self.assertIn('`--subscription`', help_text) + self.assertIn('Microsoft.CognitiveServices --subscription', help_text) + def test_deployment_parameters(self): curr_dir = os.path.dirname(os.path.realpath(__file__)) From f0bb359d1cb963180df27ec4763b84ab638c270b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 12 May 2026 05:09:37 +0000 Subject: [PATCH 3/5] Tighten provider subscription scope tests Agent-Logs-Url: https://github.com/Azure/azure-cli/sessions/3bf1023e-52e6-4455-befe-781c485502ce Co-authored-by: a0x1ab <59631311+a0x1ab@users.noreply.github.com> --- .../resource/tests/latest/test_resource_custom.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_resource_custom.py b/src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_resource_custom.py index 5ef429c6d52..a86c73645ee 100644 --- a/src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_resource_custom.py +++ b/src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_resource_custom.py @@ -259,6 +259,7 @@ def prompt_function(x): def test_feature_registration_warning_mentions_subscription_scope(self, logger_warning): for method_name, operation in [('register', register_feature), ('unregister', unregister_feature)]: with self.subTest(method_name=method_name): + logger_warning.reset_mock() client = mock.Mock() expected = object() getattr(client, method_name).return_value = expected @@ -268,12 +269,11 @@ def test_feature_registration_warning_mentions_subscription_scope(self, logger_w self.assertIs(result, expected) getattr(client, method_name).assert_called_once_with( 'Microsoft.CognitiveServices', 'OpenAI.BlockedTools.web_search') - - self.assertEqual(logger_warning.call_count, 2) - warning_message = logger_warning.call_args_list[0].args[0] - self.assertIn('current default subscription', warning_message) - self.assertIn('--subscription', warning_message) - self.assertIn('az account set', warning_message) + logger_warning.assert_called_once() + warning_message = logger_warning.call_args.args[0] + self.assertIn('current default subscription', warning_message) + self.assertIn('--subscription', warning_message) + self.assertIn('az account set', warning_message) def test_provider_register_help_mentions_subscription_scope(self): help_text = helps['provider register'] From 933cf41cae3001478ca4bbbf10601b8f3a65f0e5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 12 May 2026 05:10:13 +0000 Subject: [PATCH 4/5] Polish provider subscription guidance Agent-Logs-Url: https://github.com/Azure/azure-cli/sessions/3bf1023e-52e6-4455-befe-781c485502ce Co-authored-by: a0x1ab <59631311+a0x1ab@users.noreply.github.com> --- src/azure-cli/azure/cli/command_modules/resource/_help.py | 3 ++- .../azure/cli/command_modules/resource/custom.py | 8 ++++---- .../resource/tests/latest/test_resource_custom.py | 1 + 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/resource/_help.py b/src/azure-cli/azure/cli/command_modules/resource/_help.py index 738682c62bc..830faaead02 100644 --- a/src/azure-cli/azure/cli/command_modules/resource/_help.py +++ b/src/azure-cli/azure/cli/command_modules/resource/_help.py @@ -1748,7 +1748,8 @@ type: command short-summary: Register a provider. long-summary: By default, this command registers the provider in the current default subscription. Use - `--subscription` or run `az account set` first when you need to target a different subscription. + `--subscription` or `az account set` to change the default subscription when you need to target + another one. examples: - name: Register a provider. (autogenerated) text: | diff --git a/src/azure-cli/azure/cli/command_modules/resource/custom.py b/src/azure-cli/azure/cli/command_modules/resource/custom.py index 35155bb3822..93f6ba0aeae 100644 --- a/src/azure-cli/azure/cli/command_modules/resource/custom.py +++ b/src/azure-cli/azure/cli/command_modules/resource/custom.py @@ -3460,16 +3460,16 @@ def list_features(client, resource_provider_namespace=None): def register_feature(client, resource_provider_namespace, feature_name): logger.warning("Once the feature '%s' is registered, invoke 'az provider register -n %s' in the current " - "default subscription to get the change propagated. Use '--subscription' or run " - "'az account set' first if you need to target a different subscription.", + "default subscription to get the change propagated. Use '--subscription' or " + "'az account set' to change the default subscription if you need to target another one.", feature_name, resource_provider_namespace) return client.register(resource_provider_namespace, feature_name) def unregister_feature(client, resource_provider_namespace, feature_name): logger.warning("Once the feature '%s' is unregistered, invoke 'az provider register -n %s' in the current " - "default subscription to get the change propagated. Use '--subscription' or run " - "'az account set' first if you need to target a different subscription.", + "default subscription to get the change propagated. Use '--subscription' or " + "'az account set' to change the default subscription if you need to target another one.", feature_name, resource_provider_namespace) return client.unregister(resource_provider_namespace, feature_name) diff --git a/src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_resource_custom.py b/src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_resource_custom.py index a86c73645ee..2a4220bc1ce 100644 --- a/src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_resource_custom.py +++ b/src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_resource_custom.py @@ -276,6 +276,7 @@ def test_feature_registration_warning_mentions_subscription_scope(self, logger_w self.assertIn('az account set', warning_message) def test_provider_register_help_mentions_subscription_scope(self): + self.assertIn('provider register', helps) help_text = helps['provider register'] self.assertIn('current default subscription', help_text) self.assertIn('`--subscription`', help_text) From ad7ccfc0d1d3687e0405ed7ed0f4edd7d6469fd3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 12 May 2026 05:10:41 +0000 Subject: [PATCH 5/5] Refine provider registration examples Agent-Logs-Url: https://github.com/Azure/azure-cli/sessions/3bf1023e-52e6-4455-befe-781c485502ce Co-authored-by: a0x1ab <59631311+a0x1ab@users.noreply.github.com> --- src/azure-cli/azure/cli/command_modules/resource/_help.py | 2 +- .../resource/tests/latest/test_resource_custom.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/resource/_help.py b/src/azure-cli/azure/cli/command_modules/resource/_help.py index 830faaead02..f3aa56b58b1 100644 --- a/src/azure-cli/azure/cli/command_modules/resource/_help.py +++ b/src/azure-cli/azure/cli/command_modules/resource/_help.py @@ -1757,7 +1757,7 @@ crafted: true - name: Register a provider for a specific subscription. text: | - az provider register --namespace Microsoft.CognitiveServices --subscription 00000000-0000-0000-0000-000000000000 + az provider register --namespace Microsoft.CognitiveServices --subscription 12345678-1234-1234-1234-123456789012 - name: Register a provider from RPaaS. text: | az provider register -n 'Microsoft.Confluent' --accept-terms diff --git a/src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_resource_custom.py b/src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_resource_custom.py index 2a4220bc1ce..9d9bce0c88f 100644 --- a/src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_resource_custom.py +++ b/src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_resource_custom.py @@ -257,6 +257,7 @@ def prompt_function(x): @mock.patch('azure.cli.command_modules.resource.custom.logger.warning') def test_feature_registration_warning_mentions_subscription_scope(self, logger_warning): + feature_name = 'TestFeature' for method_name, operation in [('register', register_feature), ('unregister', unregister_feature)]: with self.subTest(method_name=method_name): logger_warning.reset_mock() @@ -264,11 +265,11 @@ def test_feature_registration_warning_mentions_subscription_scope(self, logger_w expected = object() getattr(client, method_name).return_value = expected - result = operation(client, 'Microsoft.CognitiveServices', 'OpenAI.BlockedTools.web_search') + result = operation(client, 'Microsoft.CognitiveServices', feature_name) self.assertIs(result, expected) getattr(client, method_name).assert_called_once_with( - 'Microsoft.CognitiveServices', 'OpenAI.BlockedTools.web_search') + 'Microsoft.CognitiveServices', feature_name) logger_warning.assert_called_once() warning_message = logger_warning.call_args.args[0] self.assertIn('current default subscription', warning_message)