Add an API manually

The steps in this article show how to use the Azure portal to add an API manually to the API Management (APIM) instance. A common scenario when you would want to create a blank API and define it manually is when you want to mock the API. For details about mocking an API, see Mock API responses.

If you want to import an existing API, see related topics section.

In this article, we create a blank API and specify httpbin.org (a public testing service) as a back-end API.

Prerequisites

Complete the following quickstart: Create an Azure API Management instance

Go to your API Management instance

Navigate to API Management instance

  1. Sign in to the Azure portal.

  2. Select All services.

  3. In the search box, enter api management.

  4. In the search results, select API Management services.

  5. Select your API Management service instance.

Tip

To add API Management to your favorites in the Azure portal, select the star.

The API Management icon (API Management icon) now appears in the left menu in the portal.

Create an API

  1. Select APIs from under API MANAGEMENT.

  2. From the left menu, select + Add API.

  3. Select Blank API from the list.

    Blank API

  4. Enter settings for the API.

    Settings

    Name Value Description
    Display name "Blank API" This name is displayed in the Developer portal.
    Web Service URL (optional) "https://httpbin.org" If you want to mock an API, you might not enter anything.
    In this case, we enter https://httpbin.org. This is a public testing service.
    If you want to import an API that is mapped to a back end automatically, see one of the topics in the related topics section.
    URL scheme "HTTPS" In this case, even though the back end has non-secure HTTP access, we specify a secure HTTPS APIM access to the back end.
    This kind of scenario (HTTPS to HTTP) is called HTTPS termination. You might do it if your API exists within a virtual network (where you know the access is secure even if HTTPS is not used).
    You might want to use "HTTPS termination" to save on some CPU cycles.
    URL suffix "hbin" The suffix is a name that identifies this specific API in this APIM instance. It has to be unique in this APIM instance.
    Products "Unlimited" Publish the API by associating the API with a product. If you want for the API to be published and be available to developers, add it to a product. You can do it during API creation or set it later.

    Products are associations of one or more APIs. You can include a number of APIs and offer them to developers through the developer portal.
    Developers must first subscribe to a product to get access to the API. When they subscribe, they get a subscription key that is good for any API in that product. If you created the APIM instance, you are an administrator already, so you are subscribed to every product by default.

    By default, each API Management instance comes with two sample products: Starter and Unlimited.
  5. Select Create.

At this point, you have no operations in APIM that map to the operations in your back-end API. If you call an operation that is exposed through the back end but not through the APIM, you get a 404.

Note

By default, when you add an API, even if it is connected to some back-end service, APIM will not expose any operations until you whitelist them. To whitelist an operation of your back-end service, create an APIM operation that maps to the back-end operation.

Add and test an operation

This section shows how to add a "/get" operation in order to map it to the back end "http://httpbin.org/get" operation.

Add an operation

  1. Select the API you created in the previous step.
  2. Click + Add Operation.
  3. In the URL, select GET and enter "/get" in the resource.
  4. Enter "FetchData" for Display name.
  5. Select Save.

Test an operation

Test the operation in the Azure portal. Alternatively, you can test it in the Developer portal.

  1. Select the Test tab.
  2. Select FetchData.
  3. Press Send.

The response that the "http://httpbin.org/get" operation generates appears. If you want to transform your operations, see Transform and protect your API.

Add and test a parameterized operation

This section shows how to add an operation that takes a parameter. In this case, we map the operation to "http://httpbin.org/status/200".

Add the operation

  1. Select the API you created in the previous step.
  2. Click + Add Operation.
  3. In the URL, select GET and enter "/status/{code}" in the resource. Optionally, you can provide some information associated with this parameter. For example, enter "Number" for TYPE, "200" (default) for VALUES.
  4. Enter "GetStatus" for Display name.
  5. Select Save.

Test the operation

Test the operation in the Azure portal. Alternatively, you can test it in the Developer portal.

  1. Select the Test tab.

  2. Select GetStatus. By default the code value is set to "200". You can change it to test other values. For example, type "418".

  3. Press Send.

    The response that the "http://httpbin.org/status/200" operation generates appears. If you want to transform your operations, see Transform and protect your API.

Append other APIs

An API can be composed of APIs exposed by different services, including the OpenAPI Specification, a SOAP API, the API Apps feature of Azure App Service, Azure Function App, Azure Logic Apps, and Azure Service Fabric.

Import an API

To append a different API to your existing API, complete the following steps. When you import another API, the operations are appended to your current API.

  1. Go to your Azure API Management instance in the Azure portal.
  2. Select APIs from the menu on the left.
  3. Click ... next to the API that you want to append another API to.
  4. Select Import from the drop-down menu.
  5. Select a service from which to import an API.

Next steps