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:
![](https://static.packt-cdn.com/products/9781789537222/graphics/assets/adb5e879-11aa-471d-a8e0-9a48ae440b3e.png)
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:
![](https://static.packt-cdn.com/products/9781789537222/graphics/assets/c1b45c8e-b413-4691-9e4e-7a16fba5c7f2.png)
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...