-
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] Migrate resource to track2 SDK #17783
Conversation
383c07b
to
cbaa422
Compare
ARM |
fe95df2
to
782fff3
Compare
], | ||
sender=PipelineRequestsHTTPSender(RequestsHTTPSender(smc.config)) | ||
from azure.core.pipeline import Pipeline | ||
smc._client._pipeline._impl_policies.append(JsonCTemplatePolicy()) |
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.
Consider using per_call_policies
introduced by Azure/azure-sdk-for-python#17340.
It requires azure-core
1.13.0 which is bumped by #17671.
@@ -3188,34 +3195,35 @@ def invoke_action(self, action, request_body): | |||
# Construct headers | |||
header_parameters = {} | |||
header_parameters['Content-Type'] = 'application/json; charset=utf-8' | |||
if self.rcf.resources.config.generate_client_request_id: | |||
header_parameters['x-ms-client-request-id'] = str(uuid.uuid4()) |
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.
_prepare_client_kwargs_track2
from core already configures x-ms-client-request-id
.
azure-cli/src/azure-cli-core/azure/cli/core/commands/client_factory.py
Lines 156 to 158 in 039fa21
# Prepare x-ms-client-request-id header, used by RequestIdPolicy | |
if 'x-ms-client-request-id' in cli_ctx.data['headers']: | |
client_kwargs['request_id'] = cli_ctx.data['headers']['x-ms-client-request-id'] |
I would suggest we provide a method for users to revert back to old versions of Azure CLI because these are not small changes and may break extensions, especially those not in azure-cli-extensions (#13653). |
2bed04b
to
344efa0
Compare
Deployment = cmd.get_models('Deployment', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES) | ||
deployment = Deployment(properties=properties) |
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.
Can we get the Deployment model from SDK which api-version less than 2019-10-01
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.
Yes, because in track 2, the SDK before version 2019-10-01
has added this model
Related code: code link
Deployment = cmd.get_models('Deployment', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES) | ||
deployment = Deployment(properties=properties) |
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.
Same concern as above.
b3efbbb
to
e247f5d
Compare
256d1dd
to
4c096c6
Compare
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.
Approve vm part
Description
This PR upgrades the Python SDK version of
azure-mgmt-resource
from12.1.0
to16.1.0
Here are the main changes for resource migration to track2:
begin_xxx_xxx
. For example in track1, the name iscreate_or_update
; while in track2, the name isbegin_create_or_update
.api-version
is less than2019-10-01
, the parameters of all deployment operations are changed fromDeploymentProperties
toDeployment
, which is consistent with the SDK after version2019-10-01
.begin_what_if()
:DeploymentWhatIfProperties
-->DeploymentWhatIf
begin_what_if_at_subscription_scope()/...
:DeploymentWhatIfProperties
-->ScopedDeploymentWhatIf
begin_export_template()
: flattened parameters -->ExportTemplateRequest
begin_move_resources()
: flattened parameters -->ResourcesMoveInfo
links_client.create_or_update()
:ResourceLinkProperties
-->ResourceLink
tags.create_or_update_at_scope()
: flattened parameters -->TagsResource
tags.update_at_scope()
: flattened parameters -->TagsPatchResource
get()
ofResourcesOperations
, some parameters are passed in through**kwargs
insteadCloudError
andHttpOperationError
are replaced byHttpResponseError
DeploymentOperations
becomesDeploymentOperationsOperations
For more details, please refer to this issue: remove double "operations" in operation group names autorest.python#910 (comment)
config
in management client becomes a private variable_config
.policy_definitions.create_or_update_at_management_group()
, the positions of parametersmanagement_group
andparameters
are reversed.generate_client_request_id
inResourceManagementClientConfiguration
no longer needs, SDK automatically addx-ms-request-id
now through theRequestIdPolicy
accept_language
is no longer supported inResourceManagementClientConfiguration
, so the fixed valueen-US
in track 2 is hard coded.msrest
toazure-core
. And when doing ARM deployment, the pipeline needs to add custom policyJsonCTemplatePolicy()
to support JSON templates.get_by_id()
andget()
ofResourcesOperations
no longer support parameterraw
, but passes in a callback methodcls
instead. So the custom callback functionadd_response_body()
is used to realize the logic ofinclude_response_body
.POST
operation in Swagger, so for the time being,AzureOperationPoller
ofmsrest
is still used for low-cost migration. And the request way is changed topipeline.run
in track 2.2019-08-01
,get_by_id()
andget()
ofResourcesOperations
lacked parameterapi-version
. The problem was solved by modifying the Swagger to regenerate a new Python SDK. PR link: Swagger PRKnown commands that are not covered by test
appservice domain create
appservice ase create
Migration for extension
PR link: Azure/azure-cli-extensions#3355
Live Test
result link
TODO
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 feature.
This 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.