Exposing a new API

In this section, you will learn how to add a REST API to your API Management products and how to expose the API to the developers who are using your API Management service.

We'll use an HTTP-triggered Azure function and, in particular, the Azure function created in Chapter 5Leveraging the Power of DevOps with Azure Functions.

Just to recap, the Azure function mentioned before is an HTTP-triggered function that can be called using a GET verb and return its version number:

C:\>curl --get https://masterservdevsite.azurewebsites.net/api/GetVersion?code=g5EKQzTFgdXxWXGzH2t...Q==

Your awesome function version 1.1.0.0

You want to add this REST API to your API Management products and, in the next section, you want to add policies to the API (for example, caching or a limit quota):

  1. On the API Management blade, you must choose the APIs option and, on the right-hand side, you will find various options to add a new API:

  1. Once you select Function App as the API source, you must select the existing function app:

  1. Now, you can configure it as follows:

To complete the configuration, you must insert the following:

An API can have more than one REST endpoint. In the previous sample, GetVersionAPI has only the GET verb endpoint. 

As soon as you have added the new API to your products, all the developers subscribed to those products will see the new API and will be able to use it.

The new API will also appear in the API list available on the API blade, and you can call it using the curl command:

C:\>curl --get -H "Ocp-Apim-Subscription-Key:e707a6d2b....f86064" https://masterservdevapi.azure-api.net/getversion/GetVersion

Your awesome function version 1.1.0.0

Here, the Ocp-Apim-Subscription-Key header is one of the two subscription keys for the registered user.

You can manage your API by creating a new version directly inside the Azure portal. API Management provides you with a sort of version control system that allows you to expose different versions of the same API (or the same operation inside an API) at the same time.