Training
Module
Integrate OpenAPI-enabled Web APIs with Azure API Management through Visual Studio - Training
Learn how to add an OpenAPI-enabled Web API application to Azure API Management through Visual Studio.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
APPLIES TO: All API Management tiers
This article shows how to import an "OpenAPI specification" backend API residing at https://conferenceapi.azurewebsites.net?format=json
. This backend API is provided by Microsoft and hosted on Azure. The article also shows how to test the APIM API.
In this article, you learn how to:
Note
API import limitations are documented in API import restrictions and known issues.
An API Management instance. If you don't already have one, complete the following quickstart: Create an Azure API Management instance.
Azure CLI
Use the Bash environment in Azure Cloud Shell. For more information, see Quickstart for Bash in Azure Cloud Shell.
If you prefer to run CLI reference commands locally, install the Azure CLI. If you're running on Windows or macOS, consider running Azure CLI in a Docker container. For more information, see How to run the Azure CLI in a Docker container.
If you're using a local installation, sign in to the Azure CLI by using the az login command. To finish the authentication process, follow the steps displayed in your terminal. For other sign-in options, see Sign in with the Azure CLI.
When you're prompted, install the Azure CLI extension on first use. For more information about extensions, see Use extensions with the Azure CLI.
Run az version to find the version and dependent libraries that are installed. To upgrade to the latest version, run az upgrade.
Azure PowerShell
In the Azure portal, navigate to your API Management instance.
In the left menu, select APIs > + Add API.
Under Create from definition, select OpenAPI.
Enter API settings. You can set the values during creation or configure them later by going to the Settings tab. The settings are explained in the Import and publish your first API tutorial.
Select Create.
Operations can be called directly from the portal, which provides a convenient way for administrators to view and test the operations of an API.
Select the API you created in the previous step.
Select the Test tab.
Select an operation. The page displays fields for query parameters and fields for the headers.
Note
In the test console, API Management automatically populates an Ocp-Apim-Subscription-Key header, and configures the subscription key of the built-in all-access subscription. This key enables access to every API in the API Management instance. Optionally display the Ocp-Apim-Subscription-Key header by selecting the "eye" icon next to the HTTP Request.
Depending on the operation, enter query parameter values, header values, or a request body. Select Send.
When the test is successful, the backend responds with a successful HTTP response code and some data.
Tip
By default, the test console sends a request to API Management's CORS proxy, which forwards the request to the API Management instance, which then forwards it to the backend. This proxy uses public IP address 13.91.254.72 and can only reach public endpoints. If you want to send a request directly from the browser to the API Management service, select Bypass CORS proxy. Use this option when you want to use the test console and your API Management gateway is network-isolated or doesn't allow traffic from the CORS proxy.
To debug an API, see Tutorial: Debug your APIs using request tracing.
You can compose an API of APIs exposed by different services, including:
Append a different API to your existing API using the following steps.
Note
When you import another API, the operations are appended to your current API.
Go to your Azure API Management instance in the Azure portal.
Select APIs on the Overview page or from the menu on the left.
Click ... next to the API that you want to append another API to.
Select Import from the drop-down menu.
Select a service from which to import an API.
You can configure API Management validation policies to validate requests and responses (or elements of them) against the schema in an OpenAPI specification. For example, use the validate-content policy to validate the size or content of a request or response body.
Training
Module
Integrate OpenAPI-enabled Web APIs with Azure API Management through Visual Studio - Training
Learn how to add an OpenAPI-enabled Web API application to Azure API Management through Visual Studio.