Site iconAxway Blog

Deploy an API Builder container to Google Cloud Run

How to deploy an API Builder container to Google Cloud Run

In this blog post we will see how we can easily deploy an API Builder project using Google Cloud Run. This is useful for developers that don’t or won’t have access to Axway Amplify Runtime Services (ARS) which is currently deprecated and will be discontinued effective September 1, 2022. While not free, it is an economical and straight forward solution for hosting API Builder container images.

For this blog post, you will need familiarity and access to the following:

You will also need a working and tested API Builder project.

We will describe the steps from start to finish, and when we are done we will have an API deployed in Google Cloud Run that can be publicly accessed over the internet. Most of the work involved is in setting up CLI’s (which is a one time task) and getting an API Builder Docker image into the Google Container Registry. Creating the Google Cloud Run service is actually quite quick and easy.

Log into Google Cloud and create an application

Install and configure the gcloud CLI:

Push API Builder Docker image into Google Container Registry

We need to get our API Builder Docker image into the Google Container Registry (GCR) in order to create our Cloud Run Service. I used the Stock Watchlist API Builder API described here.

There are a couple of ways to do this:

I used Cloud Build since I am running on an M1 (ARM) Silicon MacBook Air and I got a “Container failed to start” error when I started my Cloud Run service after using the Docker CLI to push my image. I checked the Troubleshoot Cloud Run issues guide and noticed issues with ARM based machines.

From inside the API Builder project, execute the following two gcloud CLI commands to use Cloud Build to push your API Builder Docker container to GCR:

gcloud config set project apib-api
gcloud builds submit --tag gcr.io/apib-api/watchlist

Note that apib-api is the Project ID of my Google Cloud project and watchlist is the name of my API Builder project. The tag needs to have the form: gcr.io/<PROJECT ID>/<ANY NAME>

Create Google Cloud Run service

Now that we have our Docker image in the Google Container Registry, we can create our service.

curl 'https://watchlist-uiqcoo2via-uc.a.run.app/api/watchlist?stocklist=aapl,txn' --header 'apikey: 123456789'

with response:

[
  {
    "symbol": "AAPL",
    "lastPrice": 149.64,
    "change": 5.8600006
  },
  {
    "symbol": "TXN",
    "lastPrice": 177.97,
    "change": 3.8399963
  }
]

You can click the EDIT & DEPLOY NEW REVISION button to make changes to any of the settings or to modify environment variables and re-deploy.

Click on the METRICS tab to see metrics related to API traffic.

Summary

Google Cloud Run offers a simple way to deploy API Builder Docker images. In this blog post we worked through the steps required to publish your API Builder API to Google Cloud Run and test it and monitor it.

To learn how to deploy an API Builder container using AWS Fargate, check out this blog post.

Need help with API Builder? Extend your skills with Axway University.

Exit mobile version