-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
{ARM} Bump api-version for Microsoft.Resources from 2021-04-01 to 2022-09-01 #25434
Conversation
@@ -61,6 +61,7 @@ class ResourceType(Enum): # pylint: disable=too-few-public-methods | |||
MGMT_RESOURCE_DEPLOYMENTSCRIPTS = ('azure.mgmt.resource.deploymentscripts', 'DeploymentScriptsClient') | |||
MGMT_RESOURCE_TEMPLATESPECS = ('azure.mgmt.resource.templatespecs', 'TemplateSpecsClient') | |||
MGMT_RESOURCE_PRIVATELINKS = ('azure.mgmt.resource.privatelinks', 'ResourcePrivateLinkClient') | |||
MGMT_RESOURCE_MANAGEDAPPLICATIONS = ('azure.mgmt.resource.managedapplications', 'ApplicationClient') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new resource type seems not being used, why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question! Thanks for your reminding!
In the past, azure.mgmt.resource.managedapplications
was a single version directory, the client path in _resource_managedapps_client_factory
was directly imported by hardcode without using ResourceType
.
azure-cli/src/azure-cli/azure/cli/command_modules/resource/_client_factory.py
Lines 49 to 52 in 946e67e
def _resource_managedapps_client_factory(cli_ctx, **_): | |
from azure.cli.core.commands.client_factory import get_mgmt_service_client | |
from azure.mgmt.resource.managedapplications import ApplicationClient | |
return get_mgmt_service_client(cli_ctx, ApplicationClient) |
In all
managedapplications
related custom methods, _resource_managedapps_client_factory()
is directly called without using the client
defined by command registration, such as:azure-cli/src/azure-cli/azure/cli/command_modules/resource/custom.py
Lines 1417 to 1432 in 946e67e
def show_application(cmd, resource_group_name=None, application_name=None): | |
""" Gets a managed application. | |
:param str resource_group_name:the resource group name | |
:param str application_name:the managed application name | |
""" | |
racf = _resource_managedapps_client_factory(cmd.cli_ctx) | |
return racf.applications.get(resource_group_name, application_name) | |
def show_applicationdefinition(cmd, resource_group_name=None, application_definition_name=None): | |
""" Gets a managed application definition. | |
:param str resource_group_name:the resource group name | |
:param str application_definition_name:the managed application definition name | |
""" | |
racf = _resource_managedapps_client_factory(cmd.cli_ctx) | |
return racf.application_definitions.get(resource_group_name, application_definition_name) |
Due to a breaking change in the SDK azure.mgmt.resource.managedapplications
, an additional directory version folder v2018_06_01
has been added to the original directory, resulting in the ModuleNotFoundError: No module named 'azure.mgmt.resource.managedapplications.operations'
issue. issue link: #25828
Therefore, we have added the new ResourceType MGMT_RESOURCE_MANAGEDAPPLICATIONS
to solve the ModuleNotFoundError
, because this way specifies the version path of the azure.mgmt.resource.managedapplications.operations
for rt in AZURE_API_PROFILES[self.cli_ctx.cloud.profile]: | |
if op_path.startswith(rt.import_prefix + '.'): | |
op_path = op_path.replace(rt.import_prefix, | |
get_versioned_sdk_path(self.cli_ctx.cloud.profile, rt, | |
operation_group=self.operation_group)) | |
try: | |
mod_to_import, attr_path = op_path.split('#') | |
handler = import_module(mod_to_import) |
More context: #24211 (comment)
Currently, there is indeed no direct use of the new resource type, which is not a good implementation way and can be confusing. I will refine the legacy code here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refined the legacy code, please help review again~
@@ -3322,15 +3322,15 @@ def create_or_update_tag_at_scope(cmd, resource_id=None, tags=None, tag_name=Non | |||
tag_obj = Tags(tags=tags) | |||
TagsResource = cmd.get_models('TagsResource') | |||
tags_resource = TagsResource(properties=tag_obj) | |||
return rcf.tags.create_or_update_at_scope(scope=resource_id, parameters=tags_resource) | |||
return rcf.tags.begin_create_or_update_at_scope(scope=resource_id, parameters=tags_resource) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't adding begin_
prefix be done during Track 2 migration? Does this create_or_update_at_scope
work currently?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be due to the sudden breaking change in the Python SDK, which forced us to do the compatibility logic. Before that, the resource module had completed the migration of most sub RPs.
The method create_or_update_at_scope
no longer exists in the Python SDK, it is directly replaced by begin_create_or_update_at_scope
.
@Jing-song Could you please help confirm whether my explanation is correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zhoxing-ms Yes, it is right.
7226abd
Related command
Issue Close: #25049 #25828
Description
Testing Guide
History Notes
[Component Name 1] BREAKING CHANGE:
az command a
: Make some customer-facing breaking change[Component Name 2]
az command b
: Add some customer-facing featureThis checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.