Skip to main content

Deploying an API Proxy on Apigee

Hands-On Lab

 

Photo of Joseph Lowery

Joseph Lowery

Google Cloud Training Architect II in Content

Length

00:45:00

Difficulty

Beginner

When developing Apigee API proxies, you're constantly making updates to the underlying code. Some changes are small, like changing the rate value on a quota policy. These modifications can be safely incorporated into the current revision with a simple save. Other alterations — like changing the name of an existing policy — are more substantial and require a new revision. In this lesson, we'll trigger such an action and learn how to deploy the new revision properly so we can test and continue developing an API proxy.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Deploying an API Proxy on Apigee

Introduction

When developing Apigee API proxies, you're constantly making updates to the underlying code. Some changes are small, like changing the rate value on a quota policy. These modifications can be safely incorporated into the current revision with a simple save. Other alterations — like changing the name of an existing policy — are more substantial and require a new revision. In this lesson, we'll trigger such an action and learn how to deploy the new revision properly so we can test and continue developing an API proxy.

Connecting to the Lab

  1. Navigate to https://cloud.google.com/apigee.
  2. Click the Try it free button.
  3. Create a free Apigee account.

Open the API Proxy

  1. On the Apigee dashboard page, click API Proxies.
  2. Select LA-Weather from the list of proxies.

Add a New Policy

  1. Click the DEVELOP tab.
  2. In the Navigator area, under Proxy Endpoints, select Preflow.
  3. In the Request flow, click + Step.
  4. In the Add Step dialog, scroll down to the MEDIATION section, and select the Extract Variables policy.
  5. Leave the Display Name and Name set to their default values, and click Add.

Customize the Policy

  1. Click the Extract Variables policy icon.
  2. Change <QueryParam name="name" /> to the following:
    <QueryParam name="q">
        <Pattern>{cityName}</Pattern>    
    </QueryParam>
  3. Click Save.

Execute a Trace Session

  1. Select the TRACE tab.
  2. In the URL field, add the following query parameters to the API proxy URI: ?q=brooklyn &appid=[YOUR_OPENWEATHERMAP_API_KEY] If you do not have a OpenWeatherMap API key, use fd4698c940c6d1da602a70ac34f0b147.
  3. Click Start Trace Session.
  4. Click Send.
  5. Note the 200 status returned by the API.
  6. In the Transaction Map, click the Extract Variables icon, and review the apigee.cityName property value.
  7. Click Stop Trace Session.
  8. Select the URL, and copy it to your clipboard.

Modify the API Proxy

  1. Select the DEVELOP tab.
  2. Click the Extract Variables policy icon.
  3. In the code, locate the <ExtractVariables> element, and change the name attribute to ExtractCityName.
  4. Change the <DisplayName> value to Extract City Name.
  5. Click Save.
  6. When the dialog appears noting that you need to save these changes as a new revision, click Save as New Revision.

Test the Modification

  1. Select the TRACE tab.
  2. Note that the URL is unavailable.
  3. Paste the copied URL into the field.
  4. Click Start Trace Session.
  5. Note that you cannot start a trace and that in the Deployment to Trace select list, only Revision 1 is available.

Deploy the New Revision

  1. Return to the DEVELOP tab.
  2. Make sure that Revision 2 is selected in the upper left corner of the screen.
  3. From the Deployment dropdown menu, select Test.
  4. In the confirmation dialog, click Deploy.
  5. After the deployment is complete, return to the TRACE tab.
  6. Paste the copied URL into the field.
  7. Click Start Trace Session.
  8. Change the town parameter from brooklyn to chicago.
  9. Click Send.
  10. Note the 200 status returned by the API.
  11. Click the Extract Variables policy icon, and review the apigee.cityName property value.

Conclusion

Congratulations, you've successfully completed this hands-on lab!