diff --git a/azure-pipelines-full-tests.yml b/azure-pipelines-full-tests.yml index 5634914d959..0fe5e7a79a7 100644 --- a/azure-pipelines-full-tests.yml +++ b/azure-pipelines-full-tests.yml @@ -16,7 +16,6 @@ variables: - template: ${{ variables.Pipeline.Workspace }}/.azure-pipelines/templates/variables.yml jobs: - - job: AutomationFullTestPython39ProfileLatest displayName: Automation Full Test Python39 Profile Latest timeoutInMinutes: 9999 diff --git a/src/azure-cli-core/azure/cli/core/_breaking_change.py b/src/azure-cli-core/azure/cli/core/_breaking_change.py index f7e51057632..ab646d13051 100644 --- a/src/azure-cli-core/azure/cli/core/_breaking_change.py +++ b/src/azure-cli-core/azure/cli/core/_breaking_change.py @@ -3,13 +3,3 @@ # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- # pylint: disable=line-too-long - -from azure.cli.core.breaking_change import AzCLIOtherChange, register_conditional_breaking_change - -register_conditional_breaking_change( - tag='CloudProfilesDeprecate', - breaking_change=AzCLIOtherChange( - cmd='', - message="Starting from 2.73.0, the azure stack profiles ('2017-03-09-profile', '2018-03-01-hybrid', '2019-03-01-hybrid', '2020-09-01-hybrid') will be deprecated. Please use the 'latest' profile or the CLI 2.66.* (LTS) version instead." - ) -) diff --git a/src/azure-cli-core/azure/cli/core/cloud.py b/src/azure-cli-core/azure/cli/core/cloud.py index 9a8c51caf0a..5ffdb6892eb 100644 --- a/src/azure-cli-core/azure/cli/core/cloud.py +++ b/src/azure-cli-core/azure/cli/core/cloud.py @@ -596,7 +596,19 @@ def get_clouds(cli_ctx): # If profile isn't set, use latest setattr(c, 'profile', 'latest') if c.profile not in API_PROFILES: - raise CLIError('Profile {} does not exist or is not supported.'.format(c.profile)) + if c.profile in ( + "2017-03-09-profile", + "2018-03-01-hybrid", + "2019-03-01-hybrid", + "2020-09-01-hybrid", + ): + logger.error( + "The azure stack profile '%s' has been deprecated and removed, using the 'latest' profile instead.\n" + "To continue using Azure Stack, please install the Azure CLI `2.66.*` (LTS) version. For more details, refer to: https://learn.microsoft.com/en-us/cli/azure/whats-new-overview#important-notice-for-azure-stack-hub-customers", c.profile + ) + c.profile = 'latest' + else: + raise CLIError('Profile {} does not exist or is not supported.'.format(c.profile)) if not c.endpoints.has_endpoint_set('management') and \ c.endpoints.has_endpoint_set('resource_manager'): # If management endpoint not set, use resource manager endpoint diff --git a/src/azure-cli-core/azure/cli/core/profiles/__init__.py b/src/azure-cli-core/azure/cli/core/profiles/__init__.py index 7681a5f63f4..ba62067c01b 100644 --- a/src/azure-cli-core/azure/cli/core/profiles/__init__.py +++ b/src/azure-cli-core/azure/cli/core/profiles/__init__.py @@ -94,10 +94,6 @@ def get_sdk(cli_ctx, resource_type, *attr_args, **kwargs): # API Profiles currently supported in the CLI. API_PROFILES = { 'latest': AZURE_API_PROFILES['latest'], - '2017-03-09-profile': AZURE_API_PROFILES['2017-03-09-profile'], - '2018-03-01-hybrid': AZURE_API_PROFILES['2018-03-01-hybrid'], - '2019-03-01-hybrid': AZURE_API_PROFILES['2019-03-01-hybrid'], - '2020-09-01-hybrid': AZURE_API_PROFILES['2020-09-01-hybrid'] } diff --git a/src/azure-cli-core/azure/cli/core/profiles/_shared.py b/src/azure-cli-core/azure/cli/core/profiles/_shared.py index d4d535f8952..0c351f5e303 100644 --- a/src/azure-cli-core/azure/cli/core/profiles/_shared.py +++ b/src/azure-cli-core/azure/cli/core/profiles/_shared.py @@ -263,156 +263,6 @@ def default_api_version(self): ResourceType.MGMT_CUSTOMLOCATION: '2021-03-15-preview', ResourceType.MGMT_CONTAINERSERVICE: SDKProfile('2025-02-01'), ResourceType.MGMT_APPCONTAINERS: '2022-10-01', - }, - '2020-09-01-hybrid': { - ResourceType.MGMT_STORAGE: '2019-06-01', - ResourceType.MGMT_NETWORK: '2018-11-01', - ResourceType.MGMT_COMPUTE: SDKProfile('2020-06-01', { - 'resource_skus': '2019-04-01', - 'disks': '2019-07-01', - 'disk_encryption_sets': '2019-07-01', - 'disk_accesses': '2020-05-01', - 'snapshots': '2019-07-01', - 'galleries': '2019-12-01', - 'gallery_images': '2019-12-01', - 'gallery_image_versions': '2019-12-01', - 'virtual_machine_scale_sets': '2020-06-01' - }), - ResourceType.MGMT_KEYVAULT: '2016-10-01', - ResourceType.MGMT_MSI: '2018-11-30', - ResourceType.MGMT_RESOURCE_FEATURES: '2021-07-01', - ResourceType.MGMT_RESOURCE_LINKS: '2016-09-01', - ResourceType.MGMT_RESOURCE_LOCKS: '2016-09-01', - ResourceType.MGMT_RESOURCE_POLICY: '2016-12-01', - ResourceType.MGMT_RESOURCE_RESOURCES: '2019-10-01', - ResourceType.MGMT_RESOURCE_SUBSCRIPTIONS: '2016-06-01', - ResourceType.MGMT_RESOURCE_TEMPLATESPECS: '2015-01-01', - ResourceType.MGMT_RESOURCE_PRIVATELINKS: '2020-05-01', - ResourceType.MGMT_RESOURCE_MANAGEDAPPLICATIONS: '2019-07-01', - ResourceType.MGMT_NETWORK_DNS: '2016-04-01', - ResourceType.MGMT_AUTHORIZATION: SDKProfile('2015-07-01', { - 'policy_assignments': '2016-12-01', - 'policy_definitions': '2016-12-01' - }), - # The order does make things different. - # Please keep ResourceType.DATA_KEYVAULT_KEYS before ResourceType.DATA_KEYVAULT - ResourceType.DATA_KEYVAULT_CERTIFICATES: None, - ResourceType.DATA_KEYVAULT_KEYS: None, - ResourceType.DATA_KEYVAULT_SECRETS: None, - ResourceType.DATA_STORAGE: '2018-11-09', - ResourceType.DATA_STORAGE_BLOB: '2019-07-07', - ResourceType.DATA_STORAGE_FILEDATALAKE: '2019-07-07', - ResourceType.DATA_STORAGE_FILESHARE: '2019-07-07', - ResourceType.DATA_STORAGE_QUEUE: '2019-07-07', - ResourceType.DATA_COSMOS_TABLE: '2017-04-17', - ResourceType.MGMT_APPSERVICE: '2018-02-01', - ResourceType.MGMT_EVENTHUB: '2022-01-01-preview', - ResourceType.MGMT_SERVICEBUS: '2022-10-01-preview', - ResourceType.MGMT_IOTHUB: '2019-07-01-preview', - ResourceType.MGMT_DATABOXEDGE: '2019-08-01', - ResourceType.MGMT_CONTAINERREGISTRY: '2019-05-01', - ResourceType.MGMT_CONTAINERSERVICE: SDKProfile('2020-11-01', { - 'container_services': '2017-07-01', - 'open_shift_managed_clusters': '2019-09-30-preview' - }) - }, - '2019-03-01-hybrid': { - ResourceType.MGMT_STORAGE: '2017-10-01', - ResourceType.MGMT_NETWORK: '2017-10-01', - ResourceType.MGMT_COMPUTE: SDKProfile('2017-12-01', { - 'resource_skus': '2017-09-01', - 'disks': '2017-03-30', - 'snapshots': '2017-03-30' - }), - ResourceType.MGMT_MSI: '2018-11-30', - ResourceType.MGMT_RESOURCE_LINKS: '2016-09-01', - ResourceType.MGMT_RESOURCE_LOCKS: '2016-09-01', - ResourceType.MGMT_RESOURCE_POLICY: '2016-12-01', - ResourceType.MGMT_RESOURCE_RESOURCES: '2018-05-01', - ResourceType.MGMT_RESOURCE_SUBSCRIPTIONS: '2016-06-01', - ResourceType.MGMT_RESOURCE_TEMPLATESPECS: '2015-01-01', - ResourceType.MGMT_RESOURCE_PRIVATELINKS: '2020-05-01', - ResourceType.MGMT_RESOURCE_MANAGEDAPPLICATIONS: '2019-07-01', - ResourceType.MGMT_NETWORK_DNS: '2016-04-01', - ResourceType.MGMT_KEYVAULT: '2016-10-01', - ResourceType.MGMT_AUTHORIZATION: SDKProfile('2015-07-01', { - 'policy_assignments': '2016-12-01', - 'policy_definitions': '2016-12-01' - }), - # The order does make things different. - # Please keep ResourceType.DATA_KEYVAULT_KEYS before ResourceType.DATA_KEYVAULT - ResourceType.DATA_KEYVAULT_CERTIFICATES: None, - ResourceType.DATA_KEYVAULT_KEYS: None, - ResourceType.DATA_KEYVAULT_SECRETS: None, - ResourceType.DATA_STORAGE: '2017-11-09', - ResourceType.DATA_STORAGE_BLOB: '2017-11-09', - ResourceType.DATA_STORAGE_FILEDATALAKE: '2017-11-09', - ResourceType.DATA_STORAGE_FILESHARE: '2017-11-09', - ResourceType.DATA_STORAGE_QUEUE: '2017-11-09', - ResourceType.DATA_COSMOS_TABLE: '2017-04-17', - # Full MultiAPI support is not done in AppService, the line below is merely - # to have commands show up in the hybrid profile which happens to have the latest - # API versions - ResourceType.MGMT_APPSERVICE: '2018-02-01', - ResourceType.MGMT_EVENTHUB: '2022-01-01-preview', - ResourceType.MGMT_SERVICEBUS: '2022-10-01-preview', - ResourceType.MGMT_IOTHUB: '2019-03-22', - ResourceType.MGMT_DATABOXEDGE: '2019-08-01' - }, - '2018-03-01-hybrid': { - ResourceType.MGMT_STORAGE: '2016-01-01', - ResourceType.MGMT_NETWORK: '2017-10-01', - ResourceType.MGMT_COMPUTE: SDKProfile('2017-03-30'), - ResourceType.MGMT_MSI: '2018-11-30', - ResourceType.MGMT_RESOURCE_LINKS: '2016-09-01', - ResourceType.MGMT_RESOURCE_LOCKS: '2016-09-01', - ResourceType.MGMT_RESOURCE_POLICY: '2016-12-01', - ResourceType.MGMT_RESOURCE_RESOURCES: '2018-02-01', - ResourceType.MGMT_RESOURCE_SUBSCRIPTIONS: '2016-06-01', - ResourceType.MGMT_RESOURCE_TEMPLATESPECS: '2015-01-01', - ResourceType.MGMT_RESOURCE_PRIVATELINKS: '2020-05-01', - ResourceType.MGMT_RESOURCE_MANAGEDAPPLICATIONS: '2019-07-01', - ResourceType.MGMT_NETWORK_DNS: '2016-04-01', - ResourceType.MGMT_KEYVAULT: '2016-10-01', - ResourceType.MGMT_AUTHORIZATION: SDKProfile('2015-07-01'), - # The order does make things different. - # Please keep ResourceType.DATA_KEYVAULT_KEYS before ResourceType.DATA_KEYVAULT - ResourceType.DATA_KEYVAULT_CERTIFICATES: None, - ResourceType.DATA_KEYVAULT_KEYS: None, - ResourceType.DATA_KEYVAULT_SECRETS: None, - ResourceType.DATA_STORAGE: '2017-04-17', - ResourceType.DATA_STORAGE_BLOB: '2017-04-17', - ResourceType.DATA_STORAGE_FILEDATALAKE: '2017-04-17', - ResourceType.DATA_STORAGE_FILESHARE: '2017-04-17', - ResourceType.DATA_STORAGE_QUEUE: '2017-04-17', - ResourceType.DATA_COSMOS_TABLE: '2017-04-17' - }, - '2017-03-09-profile': { - ResourceType.MGMT_STORAGE: '2016-01-01', - ResourceType.MGMT_NETWORK: '2015-06-15', - ResourceType.MGMT_COMPUTE: SDKProfile('2016-03-30'), - ResourceType.MGMT_MSI: '2018-11-30', - ResourceType.MGMT_RESOURCE_LINKS: '2016-09-01', - ResourceType.MGMT_RESOURCE_LOCKS: '2015-01-01', - ResourceType.MGMT_RESOURCE_POLICY: '2015-10-01-preview', - ResourceType.MGMT_RESOURCE_RESOURCES: '2016-02-01', - ResourceType.MGMT_RESOURCE_SUBSCRIPTIONS: '2016-06-01', - ResourceType.MGMT_RESOURCE_PRIVATELINKS: '2020-05-01', - ResourceType.MGMT_RESOURCE_TEMPLATESPECS: '2015-01-01', - ResourceType.MGMT_RESOURCE_MANAGEDAPPLICATIONS: '2019-07-01', - ResourceType.MGMT_NETWORK_DNS: '2016-04-01', - ResourceType.MGMT_KEYVAULT: '2016-10-01', - ResourceType.MGMT_AUTHORIZATION: SDKProfile('2015-07-01'), - # The order does make things different. - # Please keep ResourceType.DATA_KEYVAULT_KEYS before ResourceType.DATA_KEYVAULT - ResourceType.DATA_KEYVAULT_CERTIFICATES: None, - ResourceType.DATA_KEYVAULT_KEYS: None, - ResourceType.DATA_KEYVAULT_SECRETS: None, - ResourceType.DATA_STORAGE: '2015-04-05', - ResourceType.DATA_STORAGE_BLOB: '2015-04-05', - ResourceType.DATA_STORAGE_FILEDATALAKE: '2015-04-05', - ResourceType.DATA_STORAGE_FILESHARE: '2015-04-05', - ResourceType.DATA_STORAGE_QUEUE: '2015-04-05' } } @@ -420,6 +270,10 @@ def default_api_version(self): # We should avoid using ad hoc API versions, # use the version in a profile as much as possible. AD_HOC_API_VERSIONS = { + ResourceType.MGMT_IOTHUB: { + # src/azure-cli/azure/cli/command_modules/iot/custom.py#iot_hub_devicestream_show + 'iot_hub_resource': '2019-07-01-preview', + }, ResourceType.MGMT_APPSERVICE: { # src/azure-cli/azure/cli/command_modules/appservice/_constants.py:68 'app_service_certificate_orders': '2022-09-01' diff --git a/src/azure-cli-core/azure/cli/core/tests/test_cloud.py b/src/azure-cli-core/azure/cli/core/tests/test_cloud.py index e184e26b79f..4394d18f6a7 100644 --- a/src/azure-cli-core/azure/cli/core/tests/test_cloud.py +++ b/src/azure-cli-core/azure/cli/core/tests/test_cloud.py @@ -88,27 +88,7 @@ def test_add_get_cloud_with_profile(self): cli = DummyCli() endpoint_rm = 'http://management.contoso.com' endpoints = CloudEndpoints(resource_manager=endpoint_rm) - profile = '2017-03-09-profile' - c = Cloud('MyOwnCloud', endpoints=endpoints, profile=profile) - with mock.patch('azure.cli.core.cloud.CLOUD_CONFIG_FILE', tempfile.mkstemp()[1]) as\ - config_file: - add_cloud(cli, c) - config = configparser.ConfigParser() - config.read(config_file) - self.assertTrue(c.name in config.sections()) - self.assertEqual(config.get(c.name, 'endpoint_resource_manager'), endpoint_rm) - self.assertEqual(config.get(c.name, 'profile'), profile) - custom_clouds = get_custom_clouds(cli) - self.assertEqual(len(custom_clouds), 1) - self.assertEqual(custom_clouds[0].name, c.name) - self.assertEqual(custom_clouds[0].endpoints.resource_manager, c.endpoints.resource_manager) - self.assertEqual(custom_clouds[0].profile, c.profile) - - def test_add_get_cloud_with_hybrid_profile(self): - cli = DummyCli() - endpoint_rm = 'http://management.contoso.com' - endpoints = CloudEndpoints(resource_manager=endpoint_rm) - profile = '2018-03-01-hybrid' + profile = 'latest' c = Cloud('MyOwnCloud', endpoints=endpoints, profile=profile) with mock.patch('azure.cli.core.cloud.CLOUD_CONFIG_FILE', tempfile.mkstemp()[1]) as\ config_file: @@ -152,7 +132,7 @@ def test_custom_cloud_management_endpoint_set(self): endpoint_rm = 'http://management.contoso.com' endpoint_mgmt = 'http://management.core.contoso.com' endpoints = CloudEndpoints(resource_manager=endpoint_rm, management=endpoint_mgmt) - profile = '2017-03-09-profile' + profile = 'latest' c = Cloud('MyOwnCloud', endpoints=endpoints, profile=profile) with mock.patch('azure.cli.core.cloud.CLOUD_CONFIG_FILE', tempfile.mkstemp()[1]): add_cloud(cli, c) @@ -169,7 +149,7 @@ def test_custom_cloud_no_management_endpoint_set(self): cli = DummyCli() endpoint_rm = 'http://management.contoso.com' endpoints = CloudEndpoints(resource_manager=endpoint_rm) - profile = '2017-03-09-profile' + profile = 'latest' c = Cloud('MyOwnCloud', endpoints=endpoints, profile=profile) with mock.patch('azure.cli.core.cloud.CLOUD_CONFIG_FILE', tempfile.mkstemp()[1]): add_cloud(cli, c) diff --git a/src/azure-cli-core/azure/cli/core/tests/test_help.py b/src/azure-cli-core/azure/cli/core/tests/test_help.py index d6c09e67694..46204e95027 100644 --- a/src/azure-cli-core/azure/cli/core/tests/test_help.py +++ b/src/azure-cli-core/azure/cli/core/tests/test_help.py @@ -184,12 +184,12 @@ def set_help_py(self): - name: ARG4 # Note: positional's are discouraged in the CLI. short-summary: Positional parameter. Not required examples: - - name: Alpha Example + - name: Alpha Example only supported on latest text: az test alpha --arg1 a --arg2 b --arg3 c - supported-profiles: 2018-03-01-hybrid, latest + supported-profiles: latest - name: A simple example unsupported on latest text: az test alpha --arg1 a --arg2 b - unsupported-profiles: 2017-03-09-profile + unsupported-profiles: latest """ def set_help_yaml(self): @@ -230,11 +230,11 @@ def set_help_yaml(self): - summary: A simple example description: More detail on the simple example. command: az test alpha --arg1 apple --arg2 ball --arg3 cat - supported-profiles: 2018-03-01-hybrid, latest + supported-profiles: latest - summary: Another example unsupported on latest description: More detail on the unsupported example. command: az test alpha --arg1 apple --arg2 ball - unsupported-profiles: 2017-03-09-profile + unsupported-profiles: latest """ return self._create_new_temp_file(yaml_help, suffix="help.yaml") @@ -306,7 +306,7 @@ def set_help_json(self): "summary": "A simple example from json", "description": "More detail on the simple example.", "command": "az test alpha --arg1 alpha --arg2 beta --arg3 chi", - "supported-profiles": "2018-03-01-hybrid, latest" + "supported-profiles": "latest" } ] } @@ -361,24 +361,13 @@ def test_load_from_help_py(self, mocked_load, mocked_pkg_util): self.assertEqual(obj_param_dict["--arg1 -a"].value_sources[0]['link']['command'], "az foo bar") self.assertEqual(obj_param_dict["--arg1 -a"].value_sources[1]['link']['command'], "az bar baz") - if self.test_cli.cloud.profile in ['2018-03-01-hybrid', 'latest']: - self.assertEqual(command_help_obj.examples[0].short_summary, "Alpha Example") + if self.test_cli.cloud.profile in ['latest']: + self.assertEqual(len(command_help_obj.examples), 1) + self.assertEqual(command_help_obj.examples[0].short_summary, "Alpha Example only supported on latest") self.assertEqual(command_help_obj.examples[0].command, "az test alpha --arg1 a --arg2 b --arg3 c") - self.assertEqual(command_help_obj.examples[0].supported_profiles, "2018-03-01-hybrid, latest") + self.assertEqual(command_help_obj.examples[0].supported_profiles, "latest") self.assertEqual(command_help_obj.examples[0].unsupported_profiles, None) - self.assertEqual(command_help_obj.examples[1].supported_profiles, None) - self.assertEqual(command_help_obj.examples[1].unsupported_profiles, "2017-03-09-profile") - - if self.test_cli.cloud.profile == '2019-03-01-hybrid': - self.assertEqual(len(command_help_obj.examples), 1) - self.assertEqual(command_help_obj.examples[0].short_summary, "A simple example unsupported on latest") - self.assertEqual(command_help_obj.examples[0].command, "az test alpha --arg1 a --arg2 b") - self.assertEqual(command_help_obj.examples[0].unsupported_profiles, '2017-03-09-profile') - - if self.test_cli.cloud.profile == '2017-03-09-profile': - self.assertEqual(len(command_help_obj.examples), 0) - @mock.patch('pkgutil.iter_modules', side_effect=lambda x: [(None, MOCKED_COMMAND_LOADER_MOD, None)]) @mock.patch('azure.cli.core.commands._load_command_loader', side_effect=mock_load_command_loader) def test_load_from_help_yaml(self, mocked_load, mocked_pkg_util): @@ -431,25 +420,14 @@ def test_load_from_help_yaml(self, mocked_load, mocked_pkg_util): self.assertEqual(obj_param_dict["--arg2 -b"].value_sources[2]['link'], {"command": "az test show", "title": "Show test details"}) - if self.test_cli.cloud.profile in ['2018-03-01-hybrid', 'latest']: + if self.test_cli.cloud.profile in ['latest']: + self.assertEqual(len(command_help_obj.examples), 1) self.assertEqual(command_help_obj.examples[0].short_summary, "A simple example") self.assertEqual(command_help_obj.examples[0].long_summary, "More detail on the simple example.") self.assertEqual(command_help_obj.examples[0].command, "az test alpha --arg1 apple --arg2 ball --arg3 cat") - self.assertEqual(command_help_obj.examples[0].supported_profiles, "2018-03-01-hybrid, latest") + self.assertEqual(command_help_obj.examples[0].supported_profiles, "latest") self.assertEqual(command_help_obj.examples[0].unsupported_profiles, None) - self.assertEqual(command_help_obj.examples[1].supported_profiles, None) - self.assertEqual(command_help_obj.examples[1].unsupported_profiles, "2017-03-09-profile") - - if self.test_cli.cloud.profile == '2019-03-01-hybrid': - self.assertEqual(len(command_help_obj.examples), 1) - self.assertEqual(command_help_obj.examples[0].short_summary, "Another example unsupported on latest") - self.assertEqual(command_help_obj.examples[0].command, "az test alpha --arg1 apple --arg2 ball") - self.assertEqual(command_help_obj.examples[0].unsupported_profiles, '2017-03-09-profile') - - if self.test_cli.cloud.profile == '2017-03-09-profile': - self.assertEqual(len(command_help_obj.examples), 0) - @mock.patch('inspect.getmembers', side_effect=mock_inspect_getmembers) @mock.patch('pkgutil.iter_modules', side_effect=lambda x: [(None, MOCKED_COMMAND_LOADER_MOD, None)]) @mock.patch('azure.cli.core.commands._load_command_loader', side_effect=mock_load_command_loader) @@ -502,18 +480,11 @@ def test_load_from_help_json(self, mocked_load, mocked_pkg_util, mocked_getmembe self.assertEqual(obj_param_dict["--arg3"].value_sources[2]['link'], {"command": "az test show", "title": "Show test details. Json file"}) - if self.test_cli.cloud.profile in ['2018-03-01-hybrid', 'latest']: + if self.test_cli.cloud.profile in ['latest']: self.assertEqual(command_help_obj.examples[0].short_summary, "A simple example from json") self.assertEqual(command_help_obj.examples[0].long_summary, "More detail on the simple example.") self.assertEqual(command_help_obj.examples[0].command, "az test alpha --arg1 alpha --arg2 beta --arg3 chi") - self.assertEqual(command_help_obj.examples[0].supported_profiles, "2018-03-01-hybrid, latest") - - if self.test_cli.cloud.profile == '2019-03-01-hybrid': - # only supported example here - self.assertEqual(len(command_help_obj.examples), 0) - - if self.test_cli.cloud.profile == '2017-03-09-profile': - self.assertEqual(len(command_help_obj.examples), 0) + self.assertEqual(command_help_obj.examples[0].supported_profiles, "latest") # validate other parameters, which have help from help.py and help.yamls self.assertEqual(obj_param_dict["--arg1 -a"].short_summary, "A short summary.") @@ -591,20 +562,6 @@ def test_example_supported_profiles(self): mock_help_file.help_ctx.cli_ctx.cloud.profile = profile self.assertTrue(mock_help_file._should_include_example(ex_dict)) - # example should be included in all filtered profiles but not excluded profile - for excluded_profile in self.all_profiles: - filtered_profiles = [profile for profile in self.all_profiles if profile != excluded_profile] - ex_dict['supported-profiles'] = ", ".join(filtered_profiles) - - # excluded profile is not in supported-profiles list and example should be excluded - mock_help_file.help_ctx.cli_ctx.cloud.profile = excluded_profile - self.assertFalse(mock_help_file._should_include_example(ex_dict)) - - # for other profiles example should show be included. - for profile in filtered_profiles: - mock_help_file.help_ctx.cli_ctx.cloud.profile = profile - self.assertTrue(mock_help_file._should_include_example(ex_dict)) - # example should be included in the sole supported profile for sole_profile in self.all_profiles: mock_help_file.help_ctx.cli_ctx.cloud.profile = sole_profile diff --git a/src/azure-cli-core/azure/cli/core/tests/test_profile.py b/src/azure-cli-core/azure/cli/core/tests/test_profile.py index de89171abba..6e8f8563790 100644 --- a/src/azure-cli-core/azure/cli/core/tests/test_profile.py +++ b/src/azure-cli-core/azure/cli/core/tests/test_profile.py @@ -935,37 +935,6 @@ def test_normalize(self): # verify serialization works self.assertIsNotNone(json.dumps(consolidated[0])) - def test_normalize_v2016_06_01(self): - cli = DummyCli() - storage_mock = {'subscriptions': None} - profile = Profile(cli_ctx=cli, storage=storage_mock) - from azure.mgmt.resource.subscriptions.v2016_06_01.models import Subscription \ - as Subscription_v2016_06_01 - subscription = Subscription_v2016_06_01() - subscription.id = self.id1 - subscription.display_name = self.display_name1 - subscription.state = self.state1 - subscription.tenant_id = self.tenant_id - - consolidated = profile._normalize_properties(self.user1, [subscription], False) - - # The subscription shouldn't have managed_by_tenants and home_tenant_id - expected = { - 'id': '1', - 'name': self.display_name1, - 'state': 'Enabled', - 'user': { - 'name': 'foo@foo.com', - 'type': 'user' - }, - 'isDefault': False, - 'tenantId': self.tenant_id, - 'environmentName': 'AzureCloud' - } - self.assertEqual(expected, consolidated[0]) - # verify serialization works - self.assertIsNotNone(json.dumps(consolidated[0])) - def test_update_add_two_different_subscriptions(self): cli = DummyCli() storage_mock = {'subscriptions': []} @@ -1916,12 +1885,6 @@ def __init__(self, tenant_id, display_name=MOCK_TENANT_DISPLAY_NAME, default_dom class TestUtils(unittest.TestCase): - def test_attach_token_tenant_v2016_06_01(self): - from azure.mgmt.resource.subscriptions.v2016_06_01.models import Subscription - subscription = Subscription() - _attach_token_tenant(subscription, "token_tenant_1") - self.assertEqual(subscription.tenant_id, "token_tenant_1") - self.assertFalse(hasattr(subscription, "home_tenant_id")) def test_attach_token_tenant_v2022_12_01(self): from azure.mgmt.resource.subscriptions.v2022_12_01.models import Subscription diff --git a/src/azure-cli/azure/cli/command_modules/cloud/__init__.py b/src/azure-cli/azure/cli/command_modules/cloud/__init__.py index d647bd0bfa5..f7982d19fac 100644 --- a/src/azure-cli/azure/cli/command_modules/cloud/__init__.py +++ b/src/azure-cli/azure/cli/command_modules/cloud/__init__.py @@ -40,7 +40,7 @@ def load_arguments(self, command): # pylint: disable=line-too-long with self.argument_context('cloud') as c: c.argument('cloud_name', options_list=('--name', '-n'), help='Name of a registered cloud', completer=get_cloud_name_completion_list) - c.argument('profile', help='Profile to use for this cloud', choices=list(API_PROFILES)) + c.argument('profile', help='Profile to use for this cloud. The azure stack profiles `2017-03-09-profile` `2018-03-01-hybrid` `2019-03-01-hybrid` and `2020-09-01-hybrid` have been deprecated and removed. To continue using Azure Stack, please install the Azure CLI `2.66.*` (LTS) version. For more details, refer to: https://learn.microsoft.com/en-us/cli/azure/whats-new-overview#important-notice-for-azure-stack-hub-customers', choices=list(API_PROFILES)) c.argument('cloud_config', options_list=('--cloud-config',), help='JSON encoded cloud configuration. Use @{file} to load from a file.', type=shell_safe_json_parse) c.argument('endpoint_management', help='The management service endpoint') c.argument('endpoint_resource_manager', help='The resource management endpoint') diff --git a/src/azure-cli/azure/cli/command_modules/cloud/tests/latest/test_cloud.py b/src/azure-cli/azure/cli/command_modules/cloud/tests/latest/test_cloud.py index b920a8f5a19..7e0fd520c31 100644 --- a/src/azure-cli/azure/cli/command_modules/cloud/tests/latest/test_cloud.py +++ b/src/azure-cli/azure/cli/command_modules/cloud/tests/latest/test_cloud.py @@ -71,10 +71,6 @@ def test_cloud_list_profiles(self): result = self.cmd('cloud list-profiles').get_output_in_json() assert result == [ "latest", - "2017-03-09-profile", - "2018-03-01-hybrid", - "2019-03-01-hybrid", - "2020-09-01-hybrid" ] @serial_test() @@ -108,7 +104,7 @@ def test_cloud_scenario(self): # TODO: Test all arguments of `az cloud update` - self.cmd('cloud set --name {name} --profile 2020-09-01-hybrid') + self.cmd('cloud set --name {name} --profile latest') self.cli_ctx.cloud.name = self.kwargs['name'] self.cmd('cloud show', checks=[self.check('name', '{name}'),