Deploying proxies from the command line

You're viewing Apigee Edge documentation.
Go to the Apigee X documentation.
info

This topic explains how to deploy a proxy from the command line. Apigee Edge provides two options for deploying from the command line. The first is to use an Apigee Edge deploy tool written in Python. The other is to configure and run a shell script.

Use the command line deployment techniques when you are working directly with proxy source files on your system. There are many reasons why you may be working offline. You may wish to use a favorite XML editor or you may be developing policies that require Java coding and you are working primarily in an IDE. The techniques described in this section allow you to upload and deploy your source files to the API Services environment that you choose.

If you are working primarily in the management UI, see Deploying proxies in the UI.

You're viewing Apigee Edge documentation.
Go to the Apigee X documentation.
info

Running the Apigee Edge Python deploy tool

The Apigee Edge Python deploy tool works with the Edge management API to import and deploy API proxies. The tool is available as part of the API Platform Samples distribution on GitHub. See Using the sample API proxies.

Use the Apigee Edge Python tool to import (upload) and deploy your API in one simple process.

The deploy tool must be run from the base directory in the distribution of the API Platform Samples distribution, where the base directory is the parent directory of the setup and tools directory.

In the following command, substitute the proxy name, your Edge username and password, the Edge organization and environment, and the path to the directory that contains the API proxy's "apiproxy" directory:

python tools/deploy.py -n proxyname -u name:passW -o org -e env -d proxypath -p /

For example:

python tools/deploy.py -n weatherapi -u me@myCo.com:foo -o myCo -e test -d weatherapi -p /

This command zips your files, pushes them to your organization on Apigee Edge, and deploys them to the specified environment.

The deploy tool automatically discovers the current revision of your API proxy, undeploys the existing revision, and deploys an incremented revision of the API proxy.

On success you see output in the form:

Writing ./<proxybasedir>/apiproxy/weatherapi.xml to apiproxy/weatherapi.xml
Writing ./<proxybasedir>/apiproxy/proxies/default.xml to apiproxy/proxies/default.xml
Writing ./<proxybasedir>/apiproxy/targets/default.xml to apiproxy/targets/default.xml
Imported new proxy version 1
Environment: test
  Revision: 1 BasePath = /
  State: deployed

By default, the tool uploads the API proxy to https://api.enterprise.apigee.com, corresponding to Edge in the cloud. You can also use this tool to upload the API proxy to an on-premises version of Edge by specifying the -h flag:

python tools/deploy.py -n weatherapi -u me@myCo.com:foo -o myCo -e test -d weatherapi -p / -h https://192.168.11.111:8080

In this example, you specify the IP address of the Edge management server. If you have created a DNS record for the management server, you can specify a URL in the following form:

https://ms_URL:8080

The complete list of flags for the command are:

  • -n: The name of your API proxy.
  • -u: The username and password for your account in an organization in Apigee Edge.
  • -o: The name of the organization in which you have an account.
  • -e: The environment to which the API proxy should be deployed (test or prod).
  • -d: The path to the directory containing your API proxy files. Your API proxy files must be stored under a directory named "apiproxy". This value is the path of the directory that contains the "apiproxy" directory, and not to the path to the "apiproxy" directory itself.
  • -p: The URI path used as a pattern match to route incoming message to this API proxy deployment. In most cases, you can set this value to '/', unless you have advanced deployment and routing requirements. The primary path used for API proxy routing is defined in the API proxy's ProxyEndpoint configuration file.
  • -h: The Edge URL. By default, the URL is https://api.enterprise.apigee.com, corresponding to Edge in the cloud. For an on-premises deployment, use the URL of the Edge management server and port 8080, as in:
    https://ms_URL:8080

    Or, use the IP address of the management server, as in https://192.168.11.111:8080.

Configuring and running a deploy shell script

The easiest approach is to run the deploy script provided with the sample API proxy. The shell scripts wrap the Apigee Edge Python deploy tool.

From the /simplyProxy directory run:

$ sh deploy.sh

You should see:

Enter your password for user {myname} in the Apigee Enterprise organization {org_name}, followed by [ENTER]: 

Enter your password, press ENTER.

You should then see:

Deploying to test on https://api.enterprise.apigee.com using {myname} on enterprise.apigee.com and {org_name} on enterprise.apigee.com

If you see the following:

Enter your password for user Your USERNAME on enterprise.apigee.com in the Apigee Enterprise organization Your ORG on enterprise.apigee.com, followed by [ENTER]: 

it means that you need to modify the /setup/setenv.sh file in the platform samples distribution. For instructions, refer to the README or to Apigee Edge APIs.

On success, the deploy tool ZIPs up the files under /apiproxy, imports the package to your organization on Apigee Edge, and then deploys the API proxy to the 'test' environment.

Your API proxy is ready to be invoked.