question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support adding custom policies

See original GitHub issue

Is your feature request related to a problem? Please describe.

I am trying to work around https://github.com/Azure/azure-sdk-for-python/issues/8313 by adding a new custom policy called ExternalBearerTokenCredentialPolicy, but I find it difficult.

The only way to change the default policy list is to override the whole list by passing policies in ARMPipelineClient’s kwargs:

https://github.com/Azure/azure-sdk-for-python/blob/ad5308d9befefdc0cdc61c4a47a3329fd874b8a0/sdk/network/azure-mgmt-network/azure/mgmt/network/_network_management_client.py#L72-L73

When ARMPipelineClient is created without policies argument, it builds the default policy list from config=self._config:

https://github.com/Azure/azure-sdk-for-python/blob/de7168a07ec7476f589f316d2cbff6f42f8fda91/sdk/core/azure-mgmt-core/azure/mgmt/core/_pipeline_client.py#L54-L69

In order to add a custom policy to the default policy list, I must also manually create all policies created by NetworkManagementClientConfiguration:

https://github.com/Azure/azure-sdk-for-python/blob/3bf56880b6b8cc8ca7d783c96e4a5165eeb0212c/sdk/network/azure-mgmt-network/azure/mgmt/network/_configuration.py#L51-L66

This apparently seems too complicated.

Describe the solution you’d like

SDKs should expose the ability to add custom policies to the default policy list.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
johanstecommented, Feb 18, 2021

“first” and “last” does not have to mean “literally first or last in the pipeline”. “Last” can be synonymous with “do-this-for-each-try” and the first can be “do-this-once”. The names can be improved.

One (more complicated) alternative is to give policies “well known names” and have an “insert before/after” or “replace” method for it. But that is probably more power than most people would need.

0reactions
xiangyan99commented, Mar 25, 2021

Fixed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tutorial: Create a custom policy definition - Azure
In this tutorial, you craft a custom policy definition for Azure Policy to enforce custom business rules on your Azure resources.
Read more >
Creating a custom policy | Nexpose Documentation
Custom policies are editable copies of built-in policies. You can make copies of a custom policy if you need custom policies with similar...
Read more >
Step 3: Create the Custom Policies - AWS Elemental MediaLive
In IAM, create custom policies as applicable, using the IAM policy generator. This generator lets you choose the service from a list, and...
Read more >
Enable a Resource Level Support for a Custom Policy
In the XML definition file, change the standard pointcut definition as follows: · Add the following key/value pair to the YAML file: ·...
Read more >
Create or Edit a Custom Policy Template
To add specialized policies to your configuration files, you can create custom policy templates. A custom policy template can be for a packet...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found