Apigee Edge enables you to quickly expose backend services as APIs. You do this by creating an API proxy that provides a facade for the backend service that you want to expose. Apigee Edge out of the box supports the OpenAPI specification, allowing you to auto-generate API Proxies. Apigee Edge also has an OpenAPI specification editor & store which you can use to maintain your OpenAPI specifications.

The API proxy decouples your backend service implementation from the API that developers consume. This shields developers from future changes to your backend services. As you update backend services, developers, insulated from those changes, can continue to call the API uninterrupted.

The Apigee Edge Service Broker for PCF enables developers to manage APIs for their PCF apps through the Apigee Edge management console.

This lab describes how to push a sample app to Pivotal Cloud Foundry (PCF), create an Apigee Edge service instance, and bind the application to it. After binding the application to the Apigee Edge service instance, requests to the app will be forwarded to an Apigee Edge API proxy for management. This tutorial is adapted from this PCF documentation page

What you'll learn

What you'll need

How will you use use this tutorial?

Read it through only Read it and complete the exercises

How would you rate your experience with using Apigee and Pivotal Cloud Foundry?

Novice Intermediate Proficient

Codelab-at-a-conference setup

If you see a "request account button" at the top of the main Codelabs window, click it to obtain a temporary account. Otherwise ask one of the staff for a coupon with username/password.

These temporary accounts have existing projects that are set up with billing so that there are no costs associated for you with running this codelab.

Note that all these accounts will be disabled soon after the codelab is over.

Use these credentials to log into the machine or to open a new Google Cloud Console window https://console.cloud.google.com/. Accept the new account Terms of Service and any updates to Terms of Service.

Here's what you should see once logged in:

When presented with this console landing page, please select the only project available. Alternatively, from the console home page, click on "Select a Project" :

Ask one of the staff from Apigee team for environment details of Apigee and PCF

Launch Cloud Shell

Activate Google Cloud Shell

From the GCP Console click the Cloud Shell icon on the top right toolbar:

Then click "Start Cloud Shell":

It should only take a few moments to provision and connect to the environment:

This virtual machine is loaded with all the development tools you'll need. It offers a persistent 5GB home directory, and runs on the Google Cloud, greatly enhancing network performance and authentication. Much, if not all, of your work in this lab can be done with simply a browser or your Google Chromebook.

Once connected to Cloud Shell, you should see that you are already authenticated and that the project is already set to your PROJECT_ID.

Run the following command in Cloud Shell to confirm that you are authenticated:

gcloud auth list

Command output

Credentialed accounts:
 - <myaccount>@<mydomain>.com (active)
gcloud config list project

Command output

project = <PROJECT_ID>

If it is not, you can set it with this command:

gcloud config set project <PROJECT_ID>

Command output

Updated property [core/project].

Install Cloud Foundry CLI

Add the Cloud Foundry Foundation public key and package repository to your system:

$ wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo apt-key add -

$ echo "deb http://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list

Update your local package index:

$ sudo apt-get update

Install the cf CLI:

$ sudo apt-get install cf-cli

Set up the environment variables for your PCF account:

Important - Click on this link to get the environment variables and login credentials you need for the next step (The snippet below is a template and does not contain the actual variables)

If you have an issue retrieving or using the environment variables, ask your instructor. If you're completing this lab self-paced, reach out to Edgepartners@google.com.

$ export PCF_API={CF-API}
$ export PCF_ORG={PCF ORG}
$ export APIGEE_ORG={org-name}
$ export APIGEE_ENV={env-name}

Here is a brief description of the parameters




The API endpoint for your PCF Instance


The environment where you want to deploy your sample app


Domain for all the routes created in your PCF Environment


Details of the Apigee environment where your Proxies are deployed

Before you begin, you should also have separate username/password to access PCF environment and Apigee environment

Login to the PCF Environment (from your cloud shell):

$ cf api $PCF_API  --skip-ssl-validation
$ cf login


Once you login, you can also select the org and space through the following command

$ cf target -o $PCF_ORG -s $PCF_SPACE

Download the sample App to PCF

We will use a sample hello world node.js app from this git repo

$ git clone https://github.com/apigee/pivotal-cf-apigee.git
$ cd pivotal-cf-apigee/sample-api

Update your app and push it to PCF

Open manifest.yml file and change the following parameters: name: {your_initials}_helloapi, host: {your_initials}_helloapi

$ vi manifest.yml
name: {your_initials}_helloapi
host: {your_initials}_helloapi

Save the changes Esc, :wq

Push the API to PCF

cf push

Export your app's hostname to a local variable. We will use it in the subsequent steps to create an Apigee binding to the app's route

$ export PCF_APPHOST={your_initials}_helloapi

Test your app

On successful push, you should be able to see your app with the following command

You should be able to send a request, by copy/pasting the URL under the urls section of your app, to a new browser tab. http://{URL OF YOUR APP}

$ cf apps
Getting apps in org Apigee / space {PCF_SPACE} as {PCF_USER}...

name              requested state   instances   memory   disk   urls
{your_initials}_helloapi   started   1/1         128M     1G    URL OF YOUR APP

Login to Apigee, through Apigee's SSO

The following commands should give you a valid token that you can use for the next steps:

$ curl https://login.apigee.com/resources/scripts/sso-cli/ssocli-bundle.zip -o "ssocli-bundle.zip"

$ unzip ssocli-bundle.zip

$ ./get_token
<<export the token to a environment variable>>

$ export APIGEE_TOKEN={token}

Make sure apigee-edge service is available in your marketplace. If you are trying this on your own PCF instance, you should install the Apigee Edge Service Broker tile from your ops manager

$ cf marketplace

This should show apigee-edge as one of the available services.

Create service in your environment. Use the ‘org' plan to make sure the proxies are created on the public/private cloud.

$ cf create-service apigee-edge org apigee_org_service -c '{"org":"'$(echo  $APIGEE_ORG)'","env":"'$(echo  $APIGEE_ENV)'"}'

To check that the service has been enabled, try the following command

$ cf service apigee_org_service

Bind the app's route (Our Node.js app that servers the Hello API) to an Apigee ORG with the following command.

$ cf bind-route-service $PCF_DOMAIN apigee_org_service --hostname $PCF_APPHOST -c '{"org":"'$(echo  $APIGEE_ORG)'","env":"'$(echo  $APIGEE_ENV)'", "bearer":"'$(echo $APIGEE_TOKEN)'", "action":"proxy bind"}'

Login to https://apigee.com/edge

Select API Proxies

Select API Proxies

You should see an API Proxy created by the PCF Service Broker- with the following name cf-{your_initials}_helloapi.YOUR-SYSTEM-DOMAIN

Select API Proxy

Select the API and select TRACE tab on the top right

Click on the Start Trace Session, the green button on the top left

Start the Trace Session

Open a new browser tab. Send a request to the app's endpoint (this is the same endpoint you tested in your previous step)- by copy/pasting the URL under the urls section of your app, to a new browser tab. http://{URL OF YOUR APP}

If you forgot the URL OF YOUR APP, you can get if through the following command (the output will have a urls section corresponding to your app)

$ cf apps

This time, when you send the request, the request should show up in the trace of your API Proxy.


In this step, you have bound your PCF App to Apigee. PCF will now send requests to Apigee to add API Management.

You have deployed a hello world API to PCF, used Apigee's integrations to create an API Proxy. Your API is not managed.

Learn More


This work is licensed under a Creative Commons Attribution 2.0 Generic License.