What's New

From new account to running code in 5 minutes with serverless Templates

Share this post:

Using Templates for IBM Cloud Functions, you can start building serverless apps in less than 5 minutes. Literally.

What is a Template?

IBM Cloud Functions has just released a catalog of Templates to help you jump start your next serverless application. Templates can be any combination of Actions, Triggers, and Sequences connected together to form a solution. With Templates, you can quickly and easily create actions and start coding right away. Some of the Templates will require service instances from IBM Cloud. There are different Templates available, from printing new item information whenever a new item is added to a Cloudant database to setting up a periodic trigger connected to slack.

Once you’ve deployed the Template, make your own edits to the provided code, and it will quickly become your own! You can go check out the catalog of available Templates or follow along with the instructions for creating your first Template below.

Deploying Templates in IBM Cloud Functions

  1. To create a template, go to IBM Cloud Functions in the console and click ‘Start Creating’.
  2. Click ‘Deploy Template’.
  3. Select the Template you would like to create. For now, let’s try out the ‘Get HTTP Resource’ template. This template will deploy an action to fetch an external resource — in this case the Yahoo Weather API — and then return data. You might want to use a pattern like this when building a backend for a web application, especially if the resource you’re accessing needs an API Key or credentials that you don’t want exposed in your front end app or if the resource is not CORS aware.
  4. The action is enabled as a Web Action, which allows it to be invoked via a URL without an authentication key. Check out the code, and then click ‘Deploy’.
  5. Once you’ve deployed the action, click the ‘Endpoints’ tab and copy the Web Action public URL. You can now paste that URL into your browser to see this action working.
  6. If you don’t pass in a parameter, the action will return the weather for Vermont since that is set in the code as the default. You could also provide a parameter with a location to get the weather for a different location:
    https://{APIHOST}/api/v1/web/{QUALIFIED ACTION NAME}?location=Austin
    https://{APIHOST}/api/v1/web/{QUALIFIED ACTION NAME}?location=Miami
  7. You should see the weather for your chosen location!  The action received the request from your browser, then made a call to the weather API, and returned with a response.

What’s Next?

We’re excited to see this catalog grow as we continue to add Templates that are useful to you. Is there something specific you would like to see created as a Template? Feel free to share in the comments below, or by reaching out directly to our team!

Learn more about IBM Cloud Functions

IBM Cloud Developer Advocate

More What's New stories
March 11, 2019

Worker Node Auto-Scaling GA in IBM Cloud Kubernetes Service

We're extremely excited to announce the general availability of worker node auto-scaling in IBM Cloud Kubernetes Service.

Continue reading

March 8, 2019

IBM Cloud Kubernetes Service Supports CoreDNS

Kubernetes recently announced that CoreDNS has become the default cluster DNS provider starting in version 1.13. To align with this announcement, CoreDNS is also the default cluster DNS provider for new IBM Cloud Kubernetes Service version 1.13 clusters.

Continue reading

March 7, 2019

Modernize Your WebSphere Apps to the Cloud

Mix existing Java EE app capabilities and IBM Cloud services like AI and data analytics with IBM Cloud Application Platform. it combines application modernization and cloud-native application development into a single, consolidated offering.

Continue reading