Skip to content

Latest commit

 

History

History
71 lines (42 loc) · 2.2 KB

Lab302.md

File metadata and controls

71 lines (42 loc) · 2.2 KB

Lab 302: Calling a function from API Gateway

Introduction

You can invoke Oracle functions 2 million times per month for free!

If you did the basic hello-world lab listed in the pre-reqs of my previous lab. We will now be calling the same function via API Gateway.

For more details on functions with API Gateway

Another person's similar article

Pre-requisites

You have completed this lab and have a working 'hello world' function.

You have already deployed an API Gateway.

Workshop

Go to your deployed application. Now go to your helloworld function and copy the OCID.

I am able to invoke my function by typing:

fn invoke hellothere helloworld-func

Now go to your API Gateway and create a new deployment.

Upload a JSON file you create, similar to below. Your functionId should be the one you copied earlier.

{
  "requestPolicies": {},
  "routes": [
    {
      "path": "/hello",
      "methods": ["GET"],
      "backend": {
        "type": "ORACLE_FUNCTIONS_BACKEND",
        "functionId": "ocid1.fnfunc.oc1.iad.akdkads;kldsjklz37clw6pumja;lkjd;lkja4k2a"
      },
      "requestPolicies": {}
    }
  ]
}

After your deployment is created, copy the endpoing like in the last lab, and add /hello. Put this endpoint in Postman.

Congratulations, you have just invoked a serverless function via the API Gateway!

Proceed to lab 303 to see how you can use functions to perform API calls with the Python requests library.