Software Development

Build your first serverless function in 10 minutes

My teammate Upkar Lidder published a great tutorial on how to create your first serverless function very fast ⚡️. I wanted to give it a try and share the step with you here. There is nothing to download, install or configure. You can finish this tutorial in under 10 minutes ⏳.

Tutorial steps

You will complete the following steps:

  1. Create a new IBM Cloud account or sign into an existing account
  2. Create a new cloud functions
  3. Test the function
  4. Invoking as a REST API

Let’s go!

Sign-up for an IBM Cloud account

In this first step you will sign-up for a new account or log-in into an existing account.

serverless function
  1. Sign-up for an IBM Cloud account or sign-in into an existing account
    • You will get a completely free account where you can try and use cloud 40 services. You can keep it forever. That’s pretty nice!
  2. That’s it

Creating a cloud function

In this step you will create a new cloud function.

After you sign-in, open the = menu in the top-right and select Functions

serverless function
  • From the IBM Cloud Functions main page click Start Creating button
serverless function
  • From the Create page, select Create Action option
serverless function
  • On the Create Action page
    • For Action Name enter myfirstaction
    • Keep default values for Enclosing Package and Runtime
serverless function
  • Click Create button to create the Serverless function

All done. You should see the function code now.

serverless function

Testing the function

In this step we will test the function.

  1. To make it super simple, click the Invoke button (upper right). You are done.
serverless function

Now, to make it just a little bit more interesting, let’s make a super small change to the function.

  1. Change the message the function returns to I built this in 10 minutes!
  2. Click the Save button
  3. Click the Invoke button. You should see the updated message

Invoking as a REST API

In this last step you will learn how to invoke the function as a REST API.

  • On the left-hand side menu click Endpoints
  • In Web Action section, check Enable as Web Action. Click Save
serverless function
  • Copy the URL below. Open a new browser window and paste the URL into the address bar
  • You should see the result from the function
serverless function

That’s it. It was fast, right?

Summary

In this blog post you learned how to create your first serverless function. If you want to learn more and cover more advanced serverless topics, please check out the serverless Code Patterns we have available.

Published on Java Code Geeks with permission by Max Katz , partner at our JCG program. See the original article here: Build your first serverless function in 10 minutes

Opinions expressed by Java Code Geeks contributors are their own.

Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Back to top button