Blog Post

Azure Integration Services Blog
2 MIN READ

Introducing Azure API Management Policy Toolkit

akamenev's avatar
akamenev
Icon for Microsoft rankMicrosoft
Nov 19, 2024

We’re excited to announce the early release of the Azure API Management Policy Toolkit, a set of libraries and tools designed to change how developers work with API Management policies, making policy management more approachable, testable, and efficient for developers. 

Empowering developers with Azure API Management Policy Toolkit

Policies have always been at the core of Azure API Management, offering powerful capabilities to secure, change behavior, and transform requests and responses to the APIs.

Recently, we've made the policies easier to understand and manage by adding Copilot for Azure features for Azure API Management. This allows you to create and explain policies with AI help directly within the Azure portal. This powerful tool lets developers create policies using simple prompts or get detailed explanations of existing policies. This makes it much easier for new users to write policies and makes all users more productive.

Now, with the Policy Toolkit, we’re taking another significant step forward. This toolkit brings policy management even closer to the developer experience you know.

Elevating policy development experience

Azure API Management policies are written in Razor format, which for those unfamiliar with it can be difficult to read and understand, especially when dealing with large policy documents that include expressions. Testing and debugging policy changes requires deployment to a live Azure API Management instance, which slows down feedback loop even for small edits.

The Policy Toolkit addresses these challenges. You can now author your policies in C#, a language that feels natural and familiar to many developers and write tests against them. This shift improves the policy writing experience for developers, makes policies more readable, and shortens the feedback loop for policy changes.

Key toolkit features to transform your workflow:

  1. Consistent policy authoring. Write policies in C#. No more learning Razor syntax and mixing XML and C# in the same document.
  2. Syntax checking: Compile your policy documents to catch syntax errors and generate Razor-based equivalents.
  3. Unit testing: Write unit tests alongside your policies using your favorite unit testing framework.
  4. CI/CD integration: Integrate Policy Toolkit into automation pipelines for testing and compilation into Razor syntax for deployment.

Current Limitations

While we’re excited about the capabilities of the Policy Toolkit, we want to be transparent about its current limitation:

  • Not all policies are supported yet, but we’re actively working on expanding the coverage.
  • We are working on making the Policy Toolkit available as a NuGet package. In the meantime, you’ll need to build the solution on your own.
  • Unit testing is limited to policy expressions and is not supported for entire policy documents yet.

Get Started Today!

We want you to try the Azure API Management Policy Toolkit and to see if it helps streamlining your policy management workflow. Check out documentation to get started. We’re eager to hear your feedback!

By bringing policy management closer to the developer, we’re opening new possibilities to efficiently manage your API Management policies. Whether you’re using the AI-assisted approach with Copilot for Azure or diving deep into C# with the Policy Toolkit, we’re committed to making policy management more approachable and powerful.

Updated Nov 18, 2024
Version 1.0
  • DevAngel's avatar
    DevAngel
    Copper Contributor

    Intriguing. May be useful as part of deploying Azure functions with the api mgt as a front end.

  • ThomasSlippens's avatar
    ThomasSlippens
    Copper Contributor

    Very nice. I've used it to successfully create some policies that would have been a pain to create in xml last week. It took a bit of time to figure out how to structure my code for it to work, but the tests/demos that are included in the project really helped.  

    I hope it will become available as Nuget package soon! One issue i've noticed is single quotes ('') not getting escaped in the generated xml.