Azure API Management
Example of using Azure API Management
This example lives in the pulumi/examples repository. Check out just this directory to use it:
git clone --filter=blob:none --sparse https://github.com/pulumi/examples pulumi-examplesgit -C pulumi-examples sparse-checkout set classic-azure-ts-api-managementcd pulumi-examples/classic-azure-ts-api-managementAn 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
Prerequisites#
Deploying the example#
-
Create a new stack:
Terminal window pulumi stack init dev -
Log in to the Azure CLI (you will be prompted to do this during deployment if you forget this step):
Terminal window az login -
Configure the Azure environment:
Terminal window pulumi config set azure:location <location>pulumi config set azure:subscriptionId <YOUR_SUBSCRIPTION_ID> -
Install dependencies:
Terminal window npm install -
Deploy the stack:
Terminal window pulumi upPreviewing update (dev):...Updating (dev):...Resources:+ 12 createdDuration: 34m54s -
Check the deployed function endpoint:
Terminal window pulumi stack output endpointcurl --header "Ocp-Apim-Subscription-Key: $(pulumi stack output key)" $(pulumi stack output endpoint)https://greeting-service12345678.azure-api.net/hello/Pulumi{"time":"2019-06-17T15:16:08.227Z","greeting":"Hello Pulumi!"} -
Verify that the API caches the response for 30 seconds — the same time should be returned for subsequent queries:
Terminal window curl --header "Ocp-Apim-Subscription-Key: $(pulumi stack output key)" $(pulumi stack output endpoint){"time":"2019-06-17T15:16:08.227Z","greeting":"Hello Pulumi!"}
Cleaning up#
Once you are done, you can destroy all of the resources, and the stack:
pulumi destroypulumi stack rm