We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used and to tailor advertising. You can read more and make your cookie choices here. By continuing to use this site you are giving us your consent to do this.

+

Quick Start

Deploying and managing your first API

In this final segment of the Quick Start guides, you'll be taking the culmination of work from the first and second parts of this series to do the following:

  • Deploy your application to CloudHub.
  • Register your application to the API gateway to set permissions and SLA's.
  • Gain insights about your application performance with analytics and logs.

Why distribute your application on Anypoint Platform

Anypoint Platform enables quick and easy deployment, management, and discoverability of your applications. Fully utilizing the Anypoint Platform enables you and your organization to:

  • Rapidly accelerate project completion with each subsequent live API.
  • Avoid duplication/parallel development by providing API visibility.
  • Easily manage user and client application access across an organization.

Get set up

  1. You've completed both the first and second parts of this guide.

Registering an API to the gateway

With the API specification published to Exchange and an app that is ready to be deployed, you can begin the process of registering the API, setting up security policies, SLA's, and viewing analytics throughout the lifecycle of your API through API Manager.

Configuring API Manager

To deploy and register your app, you need to first configure API Manager by going to Anypoint Platform Home → Management → API Manager. You can leverage the API specification again by clicking the Manage API button → Manage API from Exchange.

All organizations by default have a Sandbox and Design environment, which can have independent configurations, policies, and proxies. The Sandbox environment will typically be limited in available resources and you may need to adjust your deployment target or worker size.

Fill in the configuration with the following information:

  • API Name: QuickStart-Store
  • API Version: “v1.0”
  • Asset Version: {{Most recent}}
  • Manage type: Basic Endpoint
  • Implementation URL:
  • Check this box…Mule 4 or above..: Checked

After clicking Save, you'll see a new screen that contains an "Autodiscovery" ID. Copy this ID to your clipboard to use it in the next step.

Adding gateway autodiscovery

In order for your app to register itself to the gateway, we need to add and configure the API Autodiscovery into your app. To add the API Autodiscovery component:

  1. Click Global Elements to view all the globally accessible elements in your Mule App.
  2. Click the Create button.
  3. Expand the Component configurations dropdown.
  4. Select API Autodiscovery and press OK.

At this point, you'll be placed with a new modal asking you to configure your Auto-discovery settings with the following:

  • API id: {{Your_API_ID_FROM_ABOVE}}
  • Flow Name: quickstart-store-main

Your Project’s XML file should look like this:
quickstart-store.xml

Obtaining organization credentials

To control apps that can register on your gateway, you'll need to provide a client ID and secret that it can use in conjunction with the API ID to provision it to the correct organization, environment, and API version. To start, go to Access ManagementEnvironments. Then click on the environment name that matches the environment from API Manager, which will show a new lightbox. Keep this window open for the next step.

Deploy from Anypoint Studio

Your tested and error-free app can now be deployed from within Anypoint Studio to CloudHub with a few simple clicks.

To start, right-click {{your_project_folder}} → Anypoint Platform → Deploy to CloudHub. This will open the application deployment window where you can select the environment you'll be publishing to (same as prior steps), set the runtime version, resource allocation, etc. 

The deployment name you want to choose may already be taken. In this case, please type in a different name for deployment that is available. Also, you may reach your worker size limit; however, your account may be provisioned enough if you reduce the worker size to “0.1 vCore”.

From the steps above, the application knows which API to associate itself with via API ID, but it doesn't have the authentication parameters needed to register. Instead of baking it into the app itself with a properties file, you'll be placing the client ID and secret from above in the properties tab of the deployment window in order to allow your app to authenticate itself and update easily should the need arise without having to edit the project (e.g. promoting from sandbox to production). Insert the following properties and replace the fields accordingly from the previous section:

anypoint.platform.client_id={{YOUR_CLIENT_ID}}
anypoint.platform.client_secret={{YOUR_CLIENT_SECRET}}

You can now deploy the app by pressing the Deploy Application button. A new window will pop-up and you can click the Open in Browser button to launch Runtime Manager.

View App insights and logs

With the Browser window displaying Runtime Manager, click on the deployed app name to view deployment stats (e.g. CPU/memory load) and logs or change deployment settings, etc:

Setting policies on deployed apps

You can now go back to API Manager and see that the "Status" column of your API "QuickStart-Store" is now marked as Active with a green dot next to it. This means the app has successfully registered with the gateway and you can manage it.

To set a rate limit policy on the app,

  1. Click v1.0.
    • This will take you to the settings for your API.
  2. Click Policies → Rate limiting → 1.0.0 → Configure Policy.
    1. You're now at the Rate limit configuration window.
  3. Configure the Rate limit to the following:
    • # of Reqs: 1
    • Time Period: 1
    • Time Unit: Minute

Press Apply and test by entering the following CURL (replace the deployed app instance name):

curl -X GET http://{{YOUR ROOT URL}}/api/products/1295527d-d3c7-11e7-9c84-06bf056d193e

This will return a response with all the product information. Now, if you are to retry the same request a second time in under a minute, you should see an error response stating "Quota has been exceeded."

Next steps

You did it! Your app is now deployed and is able to be analyzed and managed! Your app has registered itself with the gateway and can set policies and even set up SLA tiers. You can also view any client applications that have been granted access to consume your API from API Manager.

To encourage others to consume your asset and leverage this work, click the View API in Exchange link in API Manager to edit your API's portal with instructions about the API and promote its consumption through client apps.

Go to: Connecting your first SaaS applications ›