{{announcement.body}}
{{announcement.title}}

Implementing API Auto-Discovery for MuleSoft Application Deployed to CloudHub and On-Premise

DZone 's Guide to

Implementing API Auto-Discovery for MuleSoft Application Deployed to CloudHub and On-Premise

In this article, we discuss how to implement API Auto-Discovery in a MuleSoft application deployed to CloudHub or on-premise.

· Integration Zone ·
Free Resource

Introduction

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.

Prerequisites

To configure auto-discovery for your Mule application, you need to meet the following requirements:

  • API must exist in API Manager and 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 the API manager that you want to pair to.
  • You need an environment client_id and client_secret. You can get a client_id and client_secret from the AnyPoint Platform.

Configuring API Manager

To achieve API Auto-Discovery, you need to configure the API Manager. You can login to the AnyPoint Platform and navigate to API Manager to Manage API from Exchange and select your RAML.

API admin sandbox

API admin sandbox

Select Managing type as Basic Endpoint and check on "Check this box if you are managing this API in Mule 4 or above". Then, click Save.

Once you can click on Save, it will give you an API Instance Id, and that will be used for API Auto-Discovery. You will be requiring this API Instance Id to configure your application.

By default, API status is Unregistered. It will become Active, once we deploy an application to the Runtime Manager.

Getting API Instance ID

Getting API Instance ID

Configuring MuleSoft Application to Enable API Auto-Discovery

You need to add an API Auto-Discovery component in your application using the AnyPoint Platform.

Component configurations

Component configurations

This can be done using a Global configuration of your application. Then, configure your API Auto-Discovery component.

Configuring API Auto-Discovery

Configuring API Auto-Discovery

Provide the API Id that you got while configuring API Manager with the Basic Endpoint.

You need to make sure that the below four properties added to your properties file; otherwise API Auto-Discovery will not work.

Properties files


You can get Client Id and Client Secret from the AnyPoint Platform (Access Management ==> Environments).

Adding Client Id and Secret

Adding Client Id and Secret

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 the API Manager.

API Auto-Discovery gives the advantages of applying various policies for your application deployed to CloudHub or on-premise. With this, you can avoid creating proxy applications.

API status: active

API status: active


This is how you can implement API Auto-Discovery for your MuleSoft Application.

Topics:
api, api autodiscovery, cloud, cloudhub, endpoint, mulesoft, tutorial

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}