Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
180 changes: 90 additions & 90 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
@@ -1,90 +1,90 @@
name: CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
permissions:
contents: read
jobs:
build-and-test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build with dotnet
run: dotnet build --no-restore
- name: Test with dotnet
run: dotnet test --no-build --logger trx --results-directory "TestResults"
- name: Upload dotnet test results
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: dotnet-test-results-${{ matrix.os }}
path: TestResults
- name: Check format
if: ${{ always() }}
run: dotnet format style --verify-no-changes --report "FormatReport"
- name: Upload format report
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: dotnet-format-report-${{ matrix.os }}
path: FormatReport
example-project:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Create new packages
run: dotnet pack
- name: Rename example project
working-directory: ./example
run: mv Example.sln.example Example.sln
- name: Rename source.example project
working-directory: ./example/source
run: mv Source.Example.csproj.example Source.Example.csproj
- name: Rename test.example project
working-directory: ./example/test
run: mv Test.Example.csproj.example Test.Example.csproj
- name: Restore dependencies
working-directory: ./example
run: dotnet restore
- name: Restore tool
working-directory: ./example
run: dotnet tool restore
- name: Build with dotnet
working-directory: ./example
run: dotnet build --no-restore
- name: Test with dotnet
working-directory: ./example
run: dotnet test --no-build --logger trx --results-directory "TestResults"
- name: Upload dotnet test results
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: dotnet-test-results-example-${{ matrix.os }}
path: ./example/TestResults
- name: Compile policies
working-directory: ./example
run: dotnet azure-apim-policy-compiler --s ./source/ --o ./target/ --format true
name: CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

permissions:
contents: read

jobs:
build-and-test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build with dotnet
run: dotnet build --no-restore
- name: Test with dotnet
run: dotnet test --no-build --logger trx --results-directory "TestResults"
- name: Upload dotnet test results
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: dotnet-test-results-${{ matrix.os }}
path: TestResults
- name: Check format
if: ${{ always() }}
run: dotnet format style --verify-no-changes --report "FormatReport"
- name: Upload format report
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: dotnet-format-report-${{ matrix.os }}
path: FormatReport

example-project:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Create new packages
run: dotnet pack
- name: Rename example project
working-directory: ./example
run: mv Example.sln.example Example.sln
- name: Rename source.example project
working-directory: ./example/source
run: mv Source.Example.csproj.example Source.Example.csproj
- name: Rename test.example project
working-directory: ./example/test
run: mv Test.Example.csproj.example Test.Example.csproj
- name: Restore dependencies
working-directory: ./example
run: dotnet restore
- name: Restore tool
working-directory: ./example
run: dotnet tool restore
- name: Build with dotnet
working-directory: ./example
run: dotnet build --no-restore
- name: Test with dotnet
working-directory: ./example
run: dotnet test --no-build --logger trx --results-directory "TestResults"
- name: Upload dotnet test results
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: dotnet-test-results-example-${{ matrix.os }}
path: ./example/TestResults
- name: Compile policies
working-directory: ./example
run: dotnet azure-apim-policy-compiler --s ./source/ --o ./target/ --format true
18 changes: 9 additions & 9 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"recommendations": [
"ms-dotnettools.vscode-dotnet-runtime",
"ms-dotnettools.csharp",
"ms-dotnettools.csdevkit",
"ms-dotnettools.vscodeintellicode-csharp",
"editorconfig.editorconfig",
"streetsidesoftware.code-spell-checker"
]
{
"recommendations": [
"ms-dotnettools.vscode-dotnet-runtime",
"ms-dotnettools.csharp",
"ms-dotnettools.csdevkit",
"ms-dotnettools.vscodeintellicode-csharp",
"editorconfig.editorconfig",
"streetsidesoftware.code-spell-checker"
]
}
48 changes: 24 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# Azure API Management policy toolkit
**Azure API management policy toolkit** is a set of libraries and tools for authoring [**policy documents**](https://learn.microsoft.com/azure/api-management/api-management-howto-policies) for [**Azure API Management**](https://learn.microsoft.com/azure/api-management/). The toolkit was designed to help **create** and **test** policy documents with complex expressions.
Before the Policy toolkit, policy documents were written in Razor format, which is hard to read and understand, especially when there are multiple expressions. The feedback loop on new documents or even the smallest changes was very long, requiring a live Azure API Management instance, a policy document deployment, and manual testing through the API request.
The policy toolkit changes that. It allows you to write policy documents in C# language, which is more natural and doesn't require you to jump between C# and XML for expression creation. Creating policy documents in C# also brings the advantage of using simple C# code for unit testing of policy documents.
The toolkit also includes a **decompiler** that converts existing APIM policy XML documents into C# code, enabling round-trip workflows: decompile existing policies to C#, edit them, then compile back to XML. See the [available policies](docs/AvailablePolicies.md) for supported policies and the `src/Decompiling/` CLI tool for batch decompilation.
## Documentation
:exclamation: Packages are only avaliable for download from github release. We are working to bring them to public nuget.
#### Azure API Management policy toolkit documentation for users.
* [Quick start](docs/QuickStart.md)
* [Available policies](docs/AvailablePolicies.md)
* [Solution structure recommendation](docs/SolutionStructureRecommendation.md)
* [Steps for deploying policies created by the policy toolkit](docs/IntegratePolicySolution.md)
* [Integrate policy solution with APIOps](docs/IntegratePolicySolutionWithApiOps.md)
#### Azure API Management policy toolkit documentation for contributors.
* [Contributor guide](CONTRIBUTING.md)
* [Development environment setup](docs/DevEnvironmentSetup.md)
# Azure API Management policy toolkit

**Azure API management policy toolkit** is a set of libraries and tools for authoring [**policy documents**](https://learn.microsoft.com/azure/api-management/api-management-howto-policies) for [**Azure API Management**](https://learn.microsoft.com/azure/api-management/). The toolkit was designed to help **create** and **test** policy documents with complex expressions.

Before the Policy toolkit, policy documents were written in Razor format, which is hard to read and understand, especially when there are multiple expressions. The feedback loop on new documents or even the smallest changes was very long, requiring a live Azure API Management instance, a policy document deployment, and manual testing through the API request.

The policy toolkit changes that. It allows you to write policy documents in C# language, which is more natural and doesn't require you to jump between C# and XML for expression creation. Creating policy documents in C# also brings the advantage of using simple C# code for unit testing of policy documents.

The toolkit also includes a **decompiler** that converts existing APIM policy XML documents into C# code, enabling round-trip workflows: decompile existing policies to C#, edit them, then compile back to XML. See the [available policies](docs/AvailablePolicies.md) for supported policies and the `src/Decompiling/` CLI tool for batch decompilation.

## Documentation

:exclamation: Packages are only avaliable for download from github release. We are working to bring them to public nuget.

#### Azure API Management policy toolkit documentation for users.
* [Quick start](docs/QuickStart.md)
* [Available policies](docs/AvailablePolicies.md)
* [Solution structure recommendation](docs/SolutionStructureRecommendation.md)
* [Steps for deploying policies created by the policy toolkit](docs/IntegratePolicySolution.md)
* [Integrate policy solution with APIOps](docs/IntegratePolicySolutionWithApiOps.md)

#### Azure API Management policy toolkit documentation for contributors.
* [Contributor guide](CONTRIBUTING.md)
* [Development environment setup](docs/DevEnvironmentSetup.md)
22 changes: 11 additions & 11 deletions example/.config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"Microsoft.Azure.ApiManagement.PolicyToolkit.Compiling": {
"version": "1.0.0",
"commands": [
"azure-apim-policy-compiler"
]
}
}
{
"version": 1,
"isRoot": true,
"tools": {
"Microsoft.Azure.ApiManagement.PolicyToolkit.Compiling": {
"version": "1.0.0",
"commands": [
"azure-apim-policy-compiler"
]
}
}
}
8 changes: 4 additions & 4 deletions setup-example.cmd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
dotnet build
dotnet pack
cd ./example
dotnet tool restore
dotnet build
dotnet pack
cd ./example
dotnet tool restore
98 changes: 49 additions & 49 deletions src/Compiling/Compiling.csproj
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>1.0.0</Version>
<PackageId>Microsoft.Azure.ApiManagement.PolicyToolkit.Compiling</PackageId>
<Authors>Microsoft</Authors>
<Company>Microsoft Corporation</Company>
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
<Product>Azure API Management Policy Toolkit</Product>
<PackageIcon>pkgicon.png</PackageIcon>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<RepositoryUrl>https://github.com/Azure/azure-api-management-policy-toolkit</RepositoryUrl>
<PackageProjectUrl>$(RepositoryUrl)</PackageProjectUrl>
<Description>
Azure API Management Policy Toolkit Compiling is a dotnet tool allowing you to transform policy document(s) from C# code to XML.
Read more about it at https://github.com/Azure/azure-api-management-policy-toolkit
</Description>
<PackageTags>Azure;Azure API Management;API Gateway;API Management;Policy;Policies;Policy Toolkit;Compiling;Policy Toolkit Compiling</PackageTags>
<NeutralLanguage>en-US</NeutralLanguage>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>.net8</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>Microsoft.Azure.ApiManagement.PolicyToolkit.Compiling</RootNamespace>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<PackAsTool>true</PackAsTool>
<ToolCommandName>azure-apim-policy-compiler</ToolCommandName>
<PackageOutputPath>..\..\output</PackageOutputPath>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="10.0.6"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Core\Core.csproj"/>
</ItemGroup>
<ItemGroup>
<None Include="..\..\docs\images\pkgicon.png" Pack="true" PackagePath="\"/>
<None Include="README.md" Pack="true" PackagePath="\"/>
</ItemGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>1.0.0</Version>
<PackageId>Microsoft.Azure.ApiManagement.PolicyToolkit.Compiling</PackageId>
<Authors>Microsoft</Authors>
<Company>Microsoft Corporation</Company>
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
<Product>Azure API Management Policy Toolkit</Product>
<PackageIcon>pkgicon.png</PackageIcon>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<RepositoryUrl>https://github.com/Azure/azure-api-management-policy-toolkit</RepositoryUrl>
<PackageProjectUrl>$(RepositoryUrl)</PackageProjectUrl>
<Description>
Azure API Management Policy Toolkit Compiling is a dotnet tool allowing you to transform policy document(s) from C# code to XML.
Read more about it at https://github.com/Azure/azure-api-management-policy-toolkit
</Description>
<PackageTags>Azure;Azure API Management;API Gateway;API Management;Policy;Policies;Policy Toolkit;Compiling;Policy Toolkit Compiling</PackageTags>
<NeutralLanguage>en-US</NeutralLanguage>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>.net8</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>Microsoft.Azure.ApiManagement.PolicyToolkit.Compiling</RootNamespace>

<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<PackAsTool>true</PackAsTool>
<ToolCommandName>azure-apim-policy-compiler</ToolCommandName>
<PackageOutputPath>..\..\output</PackageOutputPath>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="10.0.6"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Core\Core.csproj"/>
</ItemGroup>

<ItemGroup>
<None Include="..\..\docs\images\pkgicon.png" Pack="true" PackagePath="\"/>
<None Include="README.md" Pack="true" PackagePath="\"/>
</ItemGroup>
</Project>
Loading
Loading