---
title: "Azure API Management"
description: "Example of using Azure API Management"
url: "https://www.pulumi.com/dev/examples/classic-azure-ts-api-management/"
image: "https://www.pulumi.com/assets/og/dev/examples/classic-azure-ts-api-management.png"
---

# Azure API Management

Example of using Azure API Management

- Source on GitHub: https://github.com/pulumi/examples/tree/master/classic-azure-ts-api-management
- Deploy with Pulumi: https://app.pulumi.com/new?template=https%3A%2F%2Fgithub.com%2Fpulumi%2Fexamples%2Ftree%2Fmaster%2Fclassic-azure-ts-api-management

## Get started with this example

This example lives in the [pulumi/examples](https://github.com/pulumi/examples/tree/master/classic-azure-ts-api-management) repo. Pull down just this directory to follow along:

```bash
git clone --filter=blob:none --sparse https://github.com/pulumi/examples pulumi-examples
git -C pulumi-examples sparse-checkout set classic-azure-ts-api-management
cd pulumi-examples/classic-azure-ts-api-management
```

An example Pulumi program that deploys an instance of Azure API Management with the following resources:

- API which is linked to an Azure Function App backend
- Operation and operation policy with URL rewrite and caching rules
- A product, a user, and a subscription to enable access to the API

## Running the App

1. Create a new stack:

    ```bash
    pulumi stack init dev
    ```

1. Login to Azure CLI (you will be prompted to do this during deployment if you forget this step):

    ```bash
    az login
    ```

1. Restore NPM dependencies:

    ```bash
    npm install
    ```

1. Configure Azure environment:

    ```bash
    pulumi config set azure:location <location>
    pulumi config set azure:subscriptionId <YOUR_SUBSCRIPTION_ID>
    ```

1. Run `pulumi up` to preview and deploy changes:

    ```console
    $ pulumi up
    Previewing update (dev):
    ...

    Updating (dev):
    ...
    Resources:
       + 12 created
    Duration: 34m54s
    ```

1. Check the deployed function endpoint:

    ```console
    $ pulumi stack output endpoint
    https://greeting-service12345678.azure-api.net/hello/Pulumi
    $ curl --header "Ocp-Apim-Subscription-Key: $(pulumi stack output key)" $(pulumi stack output endpoint)
    {"time":"2019-06-17T15:16:08.227Z","greeting":"Hello Pulumi!"}
    ...
    ```

1. Verify that API caches the response for 30 seconds - the same time should be returned for subsequent queries:

    ```console
    $ curl --header "Ocp-Apim-Subscription-Key: $(pulumi stack output key)" $(pulumi stack output endpoint)
    {"time":"2019-06-17T15:16:08.227Z","greeting":"Hello Pulumi!"}
    ...
    ```
