Google Cloud Functions are serverless services that respond to events, such as data coming from our device. We are now going to set up a Cloud Function to extract the data sent by the device, process it immediately, and store it in the central data storage:
- From the Google Cloud Console's left-hand menu, click on Cloud Functions and then Enable API:
Enabling the Google Cloud Functions API
- Once it is enabled, we can click on the Create function section.
- We can then define the name of our function as iiot-book-function-1 and the memory allocated as 128 MB. The trigger is Cloud Pub/Sub and the topic is signals, which we created a few paragraphs prior on the Building the devices registry section:
The definition of iiot-book-function to process the incoming message
- Under the source code section of the inline editor on the index.js tab, we can copy and...