In my previous blog, we have checked what is API management and how to create API management instance in Azure.
This article provides information on how to register new API in API management.
When you create new API management instance, by default, there is one API registered in API management – the Echo API. This API has few operations.
Also, there are 2 products by default created with the instance – starter and unlimited package. You can read more about these products on MSDN. This article does not cover how to add new products.
Pre-requisites
For registering new API, you will need access to Azure portal. If you do not have access, then you can create free account on Azure.
You will also need to create a new API management instance.
In your Visual Studio, create one web API project and publish it as App Service (app service name – azure-management-sample).
This published app service we can use as Backend API which will sit behind the API management.
Let’s get started
In API management instance you will find “+ Add API” button. Once you click on the button, you will be presented “Add a new API” panel. This panel looks as shown below.
Options available for create API
There are many options provided to add new APIs.
- Blank API: allows to add blank API which does not have any operation
- Open API: allows to directly provider OpenAPI / Swagger JSON and all the API operations would be added
- WSDL: allows to add SOAP services as APIs using WSDL
- API App: If you have API app hosted in the Azure, that can be provided and all operations would be added.
There are other options as well to use either WADL or Logic / Function app as Backend API.
Let’s start with Blank API
For this article purpose, let’s select Blank API (the first option).
Create API Panel
Once you click on “Blank API” button, it would bring up the “Create a blank API” panel.
There are two hyperlinks “Basic” and “Full” just below the panel header.
- Basic – shows only 4-5 fields which includes Display Name, Name, Web Service URL, Products. This is selected by default.
- Full – displays input boxes for all the fields as shown in below snippet.
Let’s select Full for now and the form will show more input fields.
- Display Name – the name which should be displayed in Azure portal and Developer portal
- Name – this is by default populated (spaces are replaced by hyphens)
- Description – the description of API which should be available to developer portal.
- Web Service URL – the URL where your Backend API is hosted. It can be hosted either on premise or in any cloud.
- URL scheme – which scheme should be used for transport layer
- API URL suffix – this suffix is added to API management URL. This should be unique for the API in API management.
- Tags – can be used for grouping similar APIs logically
- Products – way of packaging APIs. There are two products created by default with API Management instance.
- Version – this is checkbox. If you want to version your APIs, then this should be selected. For this article purpose, we don’t want to create versions of APIs, hence leave it unchecked.
If version is selected, then it shows additional fields asking how the version information should be provided by consumers (in headers, in query string or any other way.
Click on “Create” button. This should create the API which does not contain any operation.
Add operation to our Sample API
Once blank API is created, select that API. It should show a screen as below on the right side.
It has “+ Add Operation” button at the top. Once this button is clicked, it shows panel to add a new Frontend operation.
- Display Name – which would be displayed in the developer portal
- Name – by default populated based on value in Display Name field
- URL – Specify the HTTP option (i.e. GET, POST, PUT, DELETE) and the URL which should be appended to your “Web Service URL” specified while creating blank API
- Description – the description of operation which would be available on developer portal
- Tags – for logically organizing the API operations
There are other sections – Templates, Query, Headers, Request, Responses. For this article purpose, we will not modify anything there. The purpose of those tabs is to enable the API publisher to specify additional description on how this API operation should be called.
Once you click on Save button, the Frontend operation would be created and below screen would be shown.
As below screen shows, “/values” API is exposed on internet. It calls the Backend operation (i.e. the Web Service URL specified while creating API).
There can be inbound / outbound processing rules. They are called as policies. For this article purpose, we will skip them.
Once this is done, your new API is ready.
You can go to developer portal and check that API is visible there. You can also try calling API from the developer portal.
Wait ! What if there are many APIs?
If you have many APIs / API operations, you can select OpenAPI option while registering new API. Then provide the swagger.json file.
Azure will automatically add all of those operations in the API. Azure will also associate right descriptions for every API operation.
I hope this article provided sufficient information on creating new APIs in API management. If this article has helped you, then do comment and let me know your thoughts.
Informative
Thanks Niraj !
i want to consume SOAP service, can any one please help me by suggesting some links or any docs.
You can refer the documentation – https://docs.microsoft.com/en-us/biztalk/core/connect-to-azure-api-management