This repository provides a playground to safely experiment with and learn Azure API Management (APIM) policies in various architectures.
Repo Azure-Samples/Apim-Samples, read from GitHub 18 h ago. Azure-Samples has not joined Take My Repo.
Azure-Samples/Apim-Samples is a public repo on GitHub by Azure-Samples. This repository provides a playground to safely experiment with and learn Azure API Management (APIM) policies in various architectures. It declares the MIT license on GitHub. It is written mainly in Python, has 100 stars and last changed on 2026-11-20. Nobody has reviewed it on Take My Repo yet, which says nothing about its quality. Read from GitHub on 2026-11-21.
In the maintainer's words. Shown from GitHub; Take My Repo does not keep a copy.
This repository provides resources to quickly deploy high-fidelity Azure API Management (APIM) infrastructures and experiment with common APIM.
Historically, there were two general paths to experimenting with APIM: Standing up an entire landing zone with the APIM Landing Zone Accelerator can feel overwhelming and more than needed. Similarly, using APIM policy snippets is only helpful when an APIM instance and infrastructure already exists.
โญ APIM Samples provides common APIM infrastructures and real-world samples. Most samples can be deployed to any infrastructure, yielding an innovative and highly powerful and flexible ร la carte approach!
๐ก APIM Samples is neither too much nor too little. It is just right!
It's quick and easy to get started!
Choose your setup (pick one):
Deploy an infrastructure - Choose one based on your needs:
Run a sample - Open the desired sample's create.ipynb file and run it (nearly all samples work with all infrastructures)
Experiment - Modify policies, make API calls, and learn!
๐ก First time? Start with the Simple API Management infrastructure and the General sample. It takes ~5 minutes to deploy and costs ~$1-2/hour to run.
| Infrastructure Name | Description |
|---|---|
| API Management & Container Apps | Two MockAPI backends in Azure Container Apps with authenticated dashboards and persistent configuration through a private Blob endpoint. Compare calls through APIM with direct authenticated backend calls. Container ingress is publicly accessible; this is a learning environment, not a production security baseline. |
| Application Gateway (Private Link) & API Management & Container Apps | A secure implementation of Azure Application Gateway connecting to APIM via Private Link integration! Once traffic traverses App Gateway, it reaches APIM through a private endpoint in the VNet's private endpoint subnet. The connection from APIM to Container Apps is secured through VNet integration (and could also use Private Link). APIM Standard V2 is used here to accept the private link connection from App Gateway. |
| Application Gateway (VNet) & API Management & Container Apps | Full VNet injection of APIM and ACA! APIM is shielded from any type of traffic unless it comes through App Gateway. This offers maximum isolation for instances in which customers seek VNet injection. |
| Front Door & API Management & Container Apps | A secure implementation of Azure Front Door connecting to APIM via Private Link integration! This traffic, once it traverses through Front Door, rides entirely on Microsoft-owned and operated networks. The connection from APIM to Container Apps is secured through VNet integration (and could also use Private Link). APIM Standard V2 is used here to accept the private link connection from Front Door. |
| Simple API Management | Just the basics with a publicly accessible API Management instance fronting your APIs. This is the innermost way to experience and experiment with the APIM policies. |
Explore the MockAPI website for product information and documentation.
The four Container Apps-capable infrastructures now use MockAPI instead of the previous generic backend images. When Container Apps is enabled, each infrastructure provides two digest-pinned MockAPI instances with editable endpoints, authenticated dashboards, and persistent Blob configuration. Simple API Management and deployments with Container Apps disabled are unchanged; sample-specific external services such as Azure OpenAI, Azure Maps, and Spotify are not replaced.
/aca-1, /aca-2, and /aca-pool retain their paths. APIM rewrites backend requests to the seeded GET /hello endpoint and injects the secret X-MockAPI-Key; callers continue using their APIM subscription keys.admin username, and a generated password. Private-ingress dashboards require network access to the Container Apps environment. Clear notebook outputs before saving or sharing credentials.See the MockAPI operations guide for credentials, permissions, storage connectivity, migration, reruns, and costs. Redeploy older infrastructures before using the updated Load Balancing sample; incremental deployments do not automatically remove retired containers.
Sample names, summaries, and compatibility are maintained in the validated sample catalog. See the contributor workflow when updating these listings.
| Sample Name | Description | Supported Infrastructure(s) |
|---|---|---|
| AuthX | Authentication and role-based authorization in a mock HR API. | All infrastructures |
| AuthX Pro | Authentication and role-based authorization in a mock product with multiple APIs and policy fragments. | All infrastructures |
| Azure Maps | Proxying calls to Azure Maps with APIM policies. | All infrastructures |
| Azure OpenAI v1 Migration | Create PAYG Azure OpenAI resources, test a dated legacy API, add and test v1 alongside it, and verify the original legacy contract again. | All infrastructures |
| Costing | Track and allocate API costs per business unit using APIM subscriptions, Entra ID application tracking, and AI Gateway token/PTU tracking across both Azure OpenAI Chat Completions and Responses APIs, including streaming (SSE) token usage which is not simple to capture correctly in APIM. | All infrastructures |
| Dynamic CORS | Dynamic per-API CORS origin validation using custom policy fragments and a maintainable origin mapping. | All infrastructures |
| Egress Control | Control APIM outbound internet traffic by routing it through a Network Virtual Appliance (NVA) in a hub/spoke topology. | appgw-apim, appgw-apim-pe |
| General | Basic demo of APIM sample setup and policy usage. | All infrastructures |
| Inference Failover | Route compatible Azure OpenAI models through priority and weighted APIM backend pools with focused LLM failover and token telemetry. | All infrastructures |
| Load Balancing | Priority and weighted load balancing, circuit breaking, and recovery using throttled endpoints on infrastructure-owned MockAPI backends. No additional container is deployed. | apim-aca, afd-apim-pe |
| OAuth 3rd-Party | Authenticate with APIM which then uses its Credential Manager with Spotify's REST API. | All infrastructures |
| Secure Blob Access | Secure blob access via the valet key pattern. | All infrastructures |
Most samples work with all infrastructures, making this a truly ร la carte experience. The diagrams below show which samples are compatible with which infrastructures, and which APIM SKUs each infrastructure supports.
Use the interactive APIM Samples Developer CLI to verify setup, run tests, and manage your development workflow:
Windows:
.\start.ps1
macOS / Linux:
./start.sh
This menu-driven interface provides quick access to:
uv dependencies (refresh uv.lock)
The APIM Samples Developer CLI is not synonomous with the Azure Developer CLI. These are two separate CLIs.
This repo includes a ready-to-use APIM Samples presentation deck for demos, workshops, and stakeholder walkthroughs.
Source deck: assets/APIM-Samples-Slide-Deck.html
Presentation PDF: Azure API Management Samples - Presentation.pdf
To open the deck in your browser with a lightweight local server:
uv run python setup/serve_presentation.py
You can also launch it from the APIM Samples Developer CLI by choosing p) Serve & view presentation (auto-opens browser).
The server hosts files from assets/ and opens http://localhost:7777/APIM-Samples-Slide-Deck.html automatically. You can optionally pass a different port:
uv run python setup/serve_presentation.py 7778
To build a self-contained HTML file with images inlined for offline use or sharing:
uv run python setup/export_presentation.py
You can also run this from the APIM Samples Developer CLI by choosing e) Export presentation as self-contained HTML.
This writes the output to build/APIM-Samples-Slide-Deck.html.
assets/APIM-Samples-Slide-Deck.html while editing or iterating on the presentation.build/APIM-Samples-Slide-Deck.html when you want a portable deck that is ready to share or present offline.APIM Samples supports two setup options:
The fastest way to get started is using our pre-configured development environment. Just click the Open in GitHub Codespaces button above! Everything is pre-installed and configuredโjust sign in to Azure and you're ready to go.
This is especially helpful if you're new to APIM, unfamiliar with Python environments, or want to avoid local setup complexity. The entire setup typically takes 2-3 minutes.
GitHub Codespaces: You can also go through the menu by clicking the green "Code" button โ "Codespaces" โ "..." โ "New with options..." โ "Dev container configuration" (select Python version but ignore Default project configuration) โ "Create codespace"
๐ For detailed setup information, troubleshooting, and optimization details, see Codespaces Quickstart and Dev Container Documentation

VS Code Dev Containers: Alternatively, you can run the dev container locally by installing the Dev Containers extension, then selecting "Reopen in Container".
az login after each container startupaz login --tenant <your-tenant-id-or-domain>az account set --subscription <your-subscription-id-or-name>az account showAll prerequisites are automatically installed and configured.
These prerequisites apply broadly across all infrastructure and samples. If there are specific deviations, expect them to be noted there.
winget install --id=astral-sh.uv --version 0.9.24 -ehttps://astral.sh/uv/0.9.24/install.sh, verify SHA-256 f6e468855afb4e653fa96ed68a7cad0b2534794ece25ec202f6543c589eb04dc, then execute it.uv --versionaz login --tenant <your-tenant-id-or-domain>az account set --subscription <your-subscription-id-or-name>az account showCreate Python Environment:
uv venv
python setup/verify_dependency_age.py --scope python
uv sync --locked
Be sure to activate the terminal as per the instruction after uv venv runs.
Alternatively, you can use VS Code: Ctrl+Shift+P โ "Python: Create Environment" โ "Venv" โ Select Python version โ name: .venv. Then run the Install Dependencies (uv) task.
Complete Environment Setup: Open a terminal and start the APIM Samples Developer CLI, then select Complete environment setup.
Restart VS Code to apply all settings
Sign in to Azure: az login --tenant <your-tenant-id> and az account set --subscription <your-subscription>
Verify local setup: Start the APIM Samples Developer CLI, then select Verify local setup.
The first time you run a Jupyter notebook, you may be asked to install the Jupyter kernel package (ipykernel) if not already available.
When you open any .ipynb notebook, it will automatically use the correct kernel and all imports will work seamlessly.
create.ipynb file.User-defined Parameters header, if desired.create.ipynb Jupyter notebook via Run All.Samples can select or create a supported infrastructure when needed. Azure OpenAI v1 Migration creates sample-owned PAYG Azure OpenAI resources, tests a dated legacy API, adds v1 alongside it, and verifies the original legacy contract again.
Now that infrastructure and sample have been stood up, you can experiment with the policies, make requests against APIM, etc.
The Python helpers in this repo use standard-library logging, empowering you to control verbosity via environment variables in the root .env file. This file is created via the APIM Samples Developer CLI.
APIM_SAMPLES_LOG_LEVEL: Controls the overall verbosity (DEBUG, INFO, WARNING, ERROR, CRITICAL). Default: INFO.DEBUG, the Azure CLI runner in shared/python/azure_resources.py will also add --debug to simple az ... commands.DEBUG also shows request headers, JSON payloads, response status, headers, and bodies for ApimRequests, including test runs with printResponse=False and asynchronous polling. Known credential, token, and cookie headers are masked by default in both normal and debug output, but payloads and response bodies may contain sensitive content. Enable this only for trusted lab data and clear notebook outputs before sharing.APIM_SAMPLES_UNMASK_SENSITIVE_HEADERS: Defaults to false. Set to true to disable masking and sensitive-output suppression for Python-side data, including request and response headers, Python SDK logs, helper output, and deployment outputs. This allows logging complete APIM subscription keys and other credentials. Warning: Tokens, passwords, keys, and cookies may appear in notebook output and logs. Use only for trusted local debugging and clear outputs and logs before saving or sharing. Azure CLI still masks its own sensitive parameters and headers, including Authorization; this setting does not override Azure CLI's built-in masking. Python can log only the data the CLI returns, not recover values already masked by the CLI or a remote service. Use APIM_SAMPLES_LOG_LEVEL=DEBUG for full Python diagnostics; log-level filtering and HTTP printResponse controls still apply. Restart the notebook kernel after editing .env.APIM_SAMPLES_CONSOLE_WIDTH: Optional wrap width for long lines (defaults to 120).Encountering issues? Check our comprehensive Troubleshooting Guide! which covers:
For immediate help with common errors, diagnostic commands, and step-by-step solutions, see TROUBLESHOOTING.md.
samples folder. Samples showcase functionality and provide a baseline for your experimentation.infrastructure folder. They provide the architectural underpinnings.shared folder.bicep/modules folder. Major changes require versioning.python folder. They are not versioned yet but may be in the future.apim-policies folder.jupyter folder.create.ipynb for creation (and running) of the sample setup and a main.bicep file for IaC configuration.clean-up.ipynb file to tear down everything in the infrastructure and its resource group. This reduces your Azure cost.We provide several common architectural approaches to integrating APIM into your Azure ecosystem. While these are high-fidelity setups, they are not production-ready. Please refer to the Azure API Management landing zone accelerator for up-to-date production setups.
As you work with this repo, you will likely want to make your own customizations. There's little you need to know to be successful.
The repo uses the bicep linter and has rules defined in bicepconfig.json. See the bicep linter documentation for details.
We welcome contributions! Please consider forking the repo and creating issues and pull requests to share your samples. Please see CONTRIBUTING.md for details. Thank you!
The repository uses Ruff to maintain Python code quality standards. The configuration is located in pyproject.toml under [tool.ruff], and the APIM Samples Developer CLI supports linting.
Python modules in shared/python are covered by comprehensive unit tests located in tests/python. All tests use pytest and leverage modern pytest features, including custom markers for unit and HTTP tests. The APIM Samples Developer CLI supports testing.
Adding a new sample is relatively straight-forward.
/samples/_TEMPLATE folder.create.ipynb and main.bicep files. Look for the brackets ([ ]) brackets for specific inputs./shared/apim-policies folder instead.This project has its roots in work done by Alex Vieira on the excellent Azure API Management AI Gateway GitHub repository. Much of the structure is similar and its reuse resulted in significant time savings. Thank you, Alex!
Furthermore, Houssem Dellai was instrumental in setting up a working Front Door to API Management private connectivity lab. This created a working baseline for one of this repository's infrastructures. Thank you, Houssem!
Andrew Redman for contributing the Azure Maps sample.
Naga Venkata Cheruvu for contributing the Costing & Showback sample.
The original author of this project is Simon Kurtz.
For much more API Management content, please also check out APIM Love.
[!IMPORTANT] This software is provided for demonstration purposes only. It is not intended to be relied upon for any purpose. The creators of this software make no representations or warranties of any kind, express or implied, about the completeness, accuracy, reliability, suitability or availability with respect to the software or the information, products, services, or related graphics contained in the software for any purpose. Any reliance you place on such information is therefore strictly at your own risk.
Azure-Samples/Apim-Samples is a public repo on GitHub by Azure-Samples. This repository provides a playground to safely experiment with and learn Azure API Management (APIM) policies in various architectures.
It declares the MIT license on GitHub.
Its maker tagged it for macOS, Windows and Linux, or as Docker or cross-platform. That is declared by the maker; Take My Repo has not tested it.
Open "Take it" on its page: Take My Repo writes an install plan for your machine and hands it to your AI agent (Claude Code, Codex or Cursor), which asks you before each step. Take My Repo has not tested it on any machine.
Its last change on GitHub was on 2026-11-20. GitHub counts 18 open issues and pull requests. Take My Repo does not judge from that whether it is maintained.
Nobody has reviewed it on Take My Repo yet, which says nothing about its quality.
A curated list of awesome system integration software and resources.
Labs to explore AI Models, MCP servers, and Agents with the AI Gateway powered by Azure API Management and Microsoft Foundry ๐
21 Lessons, Get Started Building with Generative AI

12 weeks, 26 lessons, 52 quizzes, classic Machine Learning for all
Bring data to life with SVG, Canvas and HTML. :bar_chart::chart_with_upwards_trend::tada:

A sample app for the Retrieval-Augmented Generation pattern running in Azure, using Azure AI Search for retrieval and Azure OpenAI large language models to power ChatGPT-style and Q&A experiences.
Sample code for the Microsoft Cognitive Services Speech SDK
An ASP.NET Core Web App which lets sign-in users (including in your org, many orgs, orgs + personal accounts, sovereign clouds) and call Web APIs (including Microsoft Graph)
The repository for all Azure OpenAI Samples complementing the OpenAI cookbook.

A Solution Accelerator for the RAG pattern running in Azure, using Azure AI Search for retrieval and Azure OpenAI large language models to power ChatGPT-style and Q&A experiences. This includes most common requirements and best practices.
This page is also available as structured data, with the same sources and dates.
/api/v1/resources/gh/Azure-Samples/Apim-SamplesTake My Repo has not tested this on your machine. Requirements come from the project's own documentation.