Getting started with “APIGEE-EDGE”


apigee@2x

Hi readers, in this blog I am going to discuss how to start using “Apigee-Edge”.

What is Apigee-Edge?

Apigee-Edge is an API management platform which can be hosted on the Cloud or on the premises of a company and that enables companies to secure, scale, manage, and analyze their digital business, and grow API programs to meet the increase in demand.

Why Apigee-Edge?

Any application can be created either using:

(i) Monolithic Architecture

or

(ii) Microservice Based Architecture.

In the microservice based architecture, some API platform has to be used to maintain the performance measurements of the microservices created, So that, we can track the request as well as the response coming through a microservice route URL and do analysis like how many calls are made to this route for a given time period.

This is where Apigee-Edge comes into action and serves as the API platform.

Apigee-Edge Architecture?

Apigee-Edge follows a Proxy-based architecture. In a proxy-based architecture, we first need to create a Proxy Configuration and it must contain:

(i) Proxy Endpoint: It defines the URL of our API proxy, access schemes for the API proxy either HTTP or HTTPS and policies to enforce security, quota checks, and other types of access control.

and

(ii) Target Endpoint: It forward requests to the proper backend service. We can also attach policies to the TargetEndpoint to ensure that response messages are properly formatted for the app that made the initial request.

ProxyBundleApigee

So keeping this information as a base, let’s start developing our own Sample APIGEE Proxy, for that, we will use maven plugin here provided by Apigee, which will create and deploy our proxy.

Step1: Create a maven project, with the following structure:

ProjectStructureApigee

In the above project structure,

  • the Apigee module defines the proxies that we wish to deploy on Apigee.
  • HelloWorld is the proxy bundle which contains all the required policies, proxies, and resources for proxy creation,
  • a shared-pom file is an XML file which defines the plugins for Apigee and the deployment environment information.

Step2: Include the shared-pom file in the parent pom of the project, as a relative path:

sharedPOMDependency

Step3: Include the plugins provided by Apigee in the shared-pom.xml under a profile tag in the section of shared-pom.xml:
Profiles
Organization- It is your organization on which you are going to deploy your proxy bundle.
Environment- It is set to “test” here but could be “prod” or any other user-defined custom environment name for your API.
Credentials-  It defines the username and password of the user account if it is required by the Apigee, for deploying the bundle.
Step4: Include the Apigee plugin:
For this, we need to include plugins in the shared-pom.xml.
Plugins

Now that we have added Apigee plugin we can move to the next step for deploying the bundle/proxy.

Step5: Deploy to Apigee.

Open a terminal and move to the Directory containing our proxy bundle which is  HelloWorld.xml here and type the following command:

mvn install -P -Dusername= -Dpassword= -Dorg=

After we run this command, a “[info] build: success” message would be displayed on the terminal if proxy is deployed successfully on the Apigee Server otherwise a

[info] build: failure message would get displayed.

Every time we run the above command a new revision is deployed to the Apigee server and for dynamically incrementing this revision number we have set:

 overwrite=true

in our shared-pom.xml file under the configurations tag.

Step6: Verifying Deployment on Apigee and testing proxy flow. 

There we go we are done with getting our first Apigee demo up and running, we can check that by signing into our Apigee account. Congratulations!!

So when you log in to your Apigee account and click on the API Proxies tab, you can see that your HelloWorld Proxy has been deployed there, so just click on the HelloWorld Proxy and this is how it would look like in the Develop mode:

ApigeeFirstDeploy

We can see the various policies we have applied, under a policies tab on the left side panel, then comes proxy endpoints and finally any resources or scripts files that we might have used in the policies. Apigee provides us with a lot many useful policies that we can apply, more details of which could be found here: APIGEE adding Policies.

To see what is the content of your policy or proxy or any other files just click on the name of that file and you can see the code  being populated in the middle section, you may edit it here also and later can save your changes and run the proxy with those changes, but just to be cautious here once you are done implementing your changes you need to save them and later if you are happy with the changes you should download the proxy bundle by clicking on the Project drop-down. Any changes that we made on the UI are not reflected back to our local repository until we download the proxy bundle with the latest changes made and then replace local bundle with this new bundle.

Tracing your Proxy Flow:

Adjacent to the Develop tab there is a Trace tab. Just click on the start trace session to see your proxy flow. It looks like this in our example:

TracingProxy

Where the transaction map shows the complete flow of your proxy “request–response”, just click on any icon and you can see a complete trace of how that policy works, under the Phase Details section.

And in the Transactions section, we can see the 4 successful responses and the time elapsed for getting them. Elapsed time is reduced drastically after the first response is received because of the ResponseCachePolicy that we have implemented in our Proxy flow.

So that is pretty much about getting started with “Apigee-Edge”.

You can find the complete code here: Git-CodeRepo.

Hope it helps. For any queries or suggestions please feel free to comment below.

Happy Reading. 🙂 🙂


knoldus-advt-sticker


Advertisements
This entry was posted in Microservices. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s