Author: Jitendra Bafna
API Auto Discovery is a mechanism that manages an API from API Manager by pairing the deployed application to an API created on the platform. API Management includes tracking, enforcing policies if you apply any, and reporting API analytics. Critical to the Auto discovery process is identifying the API by providing the API name and version.
To configure auto discovery for your Mule application you need to meet the following requirements:
- API must exist in API Manager, configured with either a basic endpoint, or a proxy endpoint.
- Mule must be configured to use AnyPoint Platform credentials.
- The auto discovery element must be configured in your Mule application. This XML element must point to the specific API in API manager which you want to pair to.
- Need environment client_id and client_secret. You can get client_id and client_secret from AnyPoint Platform.
Configuring API Manager
To achieve API Auto Discovery, you need to configure API Manager. You can login to AnyPoint Platform and navigate to API Manager => Manage API from Exchange and select your RAML.
Select Managing type as Basic Endpoint ad check on “Check this box if you are managing this API in Mule 4 or above“. Click Save.
Once you can click on Save, it will give you API Instance Id and that will be used for API Auto Discovery. You will be requiring this API Instance Id to configure in your application.
By default, API status is Unregistered. It will become Active, once we deploy an application to the Runtime Manager.
Configuring MuleSoft Application to enable API Auto Discovery
You need to add an API Auto Discovery component in your application using AnyPoint Platform.
This can be done using Global configuration of your application. Configure API Auto Discovery component.
Provide API Id that you got while configuring API Manager with Basic Endpoint.
You need to make sure that below four properties added to your properties file otherwise API Auto Discovery will not work.
You can get Client Id and Client Secret from AnyPoint Platform (Access Management ==> Environments).
After configuring API Auto Discovery and properties, you need to run the application using AnyPoint Studio and API will become Active in API Manager.
Even once you deploy an application to MuleSoft CloudHub Runtime Manager or MuleSoft On Premise Runtime, API will be Active in API Manager.
API Auto Discovery gives the advantages where you can apply various Policies for your application deployed to CloudHub or on premise. You can avoid creating proxy applications.
Video Link: https://youtu.be/JaWvSuKn__8
This is how you can implement API Auto Discovery for your MuleSoft Application.