-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Description
- Package Name:
azure-core - Package Version:
1.13.0 - Operating System: All
- Python Version: All
Describe the bug
Although a PR has added the ability to add the custom policies when no specified policies are passed in through **kwargs to the PipelineClient.
PR link: #17340
However, management client still does not support adding custom policies.
For example, the per_call_policies or per_retry_policies is passed in through **kwargs when building ResourceManagementClient. The reason for this issue is as follows:
-
In method
__init__()ofResourceManagementClient, theARMPipelineClientis created
Line 80 in 6025370
self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) -
When creating
ARMPipelineClient, if the specified policies are not passed in through**kwargs, the default policies will be added to**kwargsbefore building the pipeline
azure-sdk-for-python/sdk/core/azure-mgmt-core/azure/mgmt/core/_pipeline_client.py
Lines 44 to 51 in 6025370
def __init__(self, base_url, **kwargs): if "policies" not in kwargs: if "config" not in kwargs: raise ValueError( "Current implementation requires to pass 'config' if you don't pass 'policies'" ) kwargs["policies"] = self._default_policies(**kwargs) super(ARMPipelineClient, self).__init__(base_url, **kwargs) -
When building pipeline, only when there are no policies in
**kwargs, there is logic to add custom policies. Since the default policies are passed in through**kwargsin step 2, so there is no logic to add custom policies.
azure-sdk-for-python/sdk/core/azure-core/azure/core/_pipeline_client.py
Lines 111 to 117 in 6025370
def _build_pipeline(self, config, **kwargs): # pylint: disable=no-self-use transport = kwargs.get('transport') policies = kwargs.get('policies') if policies is None: # [] is a valid policy list per_call_policies = kwargs.get('per_call_policies', []) per_retry_policies = kwargs.get('per_retry_policies', [])
Expected behavior
Could we consider that when building pipeline client, if the specified policies are passed in through **kwargs, these policies (in ARMPipelineClient, they are the default policies set by _default_policies) can also support appending custom policies?
ETA
Because this issue affects our migration of track 2 for resource module, and we plan to complete the merge of the migrated code by next Monday.
So this is an urgent issue and we hope to have it resolved by next Monday. Otherwise, we have to add custom policies by modifying private variables which do not conform to the code specification.