Over a million developers have joined DZone.

GCP: Using Cloud Functions [Snippet]

DZone 's Guide to

GCP: Using Cloud Functions [Snippet]

Here, we take a look at how to quickly get up and running with your first JavaScript cloud function in Google Cloud Platform.

· Cloud Zone ·
Free Resource

In this post and this post, I wrote about how you might create a basic Azure function. In this post, I’ll do the same thing using the Google Cloud Platform (GCP).

Google Cloud Functions

This is what Google refers to as their serverless function offering. The feature is, at the time of writing, still in beta and only allows JavaScript functions (although after the amount of advertising they have been doing on Dot Net Rocks, I did look for a while for the C# switch).

As with many of the Google features, you need to enable functions for the project that you’re in:

Image title

Once the API is enabled, you’ll have the opportunity to create a new function; doing so should present you with this screen:

Image title

Since the code has to be in JavaScript, you could use the following (which is a cut down version of the default code):

exports.helloWorld = function helloWorld(req, res) {

    res.status(200).send('Test function');


Once you create the function, you’ll see it spin for a while before it declares that you’re ready to go:

Image title


In order to test that this works, simply navigate to the URL given earlier on:

Image title

cloud ,google cloud functions ,javascript ,google cloud platform

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}