-
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
{Resource} Remove direct call to msrestazure
#29959
base: dev
Are you sure you want to change the base?
Conversation
️✔️AzureCLI-FullTest
|
Hi @Jing-song, |
️✔️AzureCLI-BreakingChangeTest
|
Resource |
Could you please help migrate the usage of |
Done |
def get_long_running_status(status_link, headers=None): | ||
request = client.get(status_link, query_parameters, header_parameters) | ||
if headers: | ||
request.headers.update(headers) | ||
pipeline_response = client._pipeline.run(request, stream=False) | ||
return pipeline_response.http_response.internal_response | ||
|
||
def get_long_running_output(response): | ||
from azure.core.exceptions import HttpResponseError | ||
if response.status_code not in [200, 202, 204]: | ||
exp = HttpResponseError(response) | ||
exp.request_id = response.headers.get('x-ms-request-id') | ||
raise exp | ||
return response.text | ||
|
||
return AzureOperationPoller(long_running_send, get_long_running_output, get_long_running_status) | ||
def deserialization_cb(pipeline_response): | ||
return json.loads(pipeline_response.http_response.text()) | ||
|
||
request = client.post(url, query_parameters, header_parameters, **body_content_kwargs) | ||
pipeline_response = client._pipeline.run(request, stream=False) | ||
|
||
return LROPoller(client=client, initial_response=pipeline_response, deserialization_callback=deserialization_cb, | ||
polling_method=ARMPolling(lro_options={"final-state-via": "azure-async-operation"})) |
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.
Could we still obtain the long running status after the migration?
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.
@@ -109,7 +109,7 @@ def internal_validate_lock_parameters(namespace, resource_group, resource_provid | |||
parent_resource_path, resource_type, resource_name): | |||
if resource_group is None: | |||
if resource_name is not None: | |||
from msrestazure.tools import parse_resource_id, is_valid_resource_id | |||
from azure.mgmt.core.tools import parse_resource_id, is_valid_resource_id |
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.
I think this change is already covered by #29856.
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.
Why is this test re-recorded?
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.
I have re-recorded the test that included the invoice-action
command.
def deserialization_cb(pipeline_response): | ||
return json.loads(pipeline_response.http_response.text()) | ||
|
||
request = client.post(url, query_parameters, header_parameters, **body_content_kwargs) | ||
pipeline_response = client._pipeline.run(request, stream=False) | ||
|
||
return LROPoller(client=client, initial_response=pipeline_response, deserialization_callback=deserialization_cb, | ||
polling_method=ARMPolling(lro_options={"final-state-via": "azure-async-operation"})) |
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.
I am not an expert on this part, but this process seems to be pretty generic. Do we have to re-define the whole LRO process?
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.
Please wait until #29856 is merged.
pipeline_response = client._pipeline.run(request, stream=False) | ||
|
||
return LROPoller(client=client, initial_response=pipeline_response, deserialization_callback=deserialization_cb, | ||
polling_method=ARMPolling(lro_options={"final-state-via": "azure-async-operation"})) |
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.
I understand the name azure-async-operation
is from SDK (https://github.com/Azure/azure-sdk-for-python/blob/54b2d3701a530628d52936193c3a5f564fbbee73/sdk/core/azure-mgmt-core/azure/mgmt/core/polling/arm_polling.py#L69), but it is super confusing as the header name in the HTTP response is Azure-AsyncOperation
as documented by https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/async-operations. azure-async-operation
is never used in any place.
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.
It is an option to choose to get the final URL, I will not specify it and let it decide for itself.
def deserialization_cb(pipeline_response): | ||
return json.loads(pipeline_response.http_response.text()) | ||
|
||
request = client.post(url, query_parameters, header_parameters, **body_content_kwargs) |
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.
I am surprised that SDK has no equivalent function and we have to construct the POST
request by ourselves.
Related command
az resource invoke-action
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.