You have created a code snippet that should be triggered whenever a new file is uploaded to a Cloud Storage bucket. You want to deploy this code snippet. What should you do?
A.
Use App Engine and configure Cloud Scheduler to trigger the application using Pub/Sub.
B.
Use Cloud Functions and configure the bucket as a trigger resource.
C.
Use Google Kubernetes Engine and configure a CronJob to trigger the application using Pub/Sub.
D.
Use Dataflow as a batch job, and configure the bucket as a data source.
Correct Answer is (B):
Google Cloud Storage Triggers
Cloud Functions can respond to change notifications emerging from Google Cloud Storage. These notifications can be configured to trigger in response to various events inside a bucket—object creation, deletion, archiving and metadata updates.
Note: Cloud Functions can only be triggered by Cloud Storage buckets in the same Google Cloud Platform project.
Event types
Cloud Storage events used by Cloud Functions are based on Cloud Pub/Sub Notifications for Google Cloud Storage and can be configured in a similar way.
Supported trigger type values are:
google.storage.object.finalize
google.storage.object.delete
google.storage.object.archive
google.storage.object.metadataUpdate
Object Finalize
Trigger type value: google.storage.object.finalize
This event is sent when a new object is created (or an existing object is overwritten, and a new generation of that object is created) in the bucket.
https://cloud.google.com/functions/docs/calling/storage#event_types
Google Cloud Functions supports several types of triggers, allowing you to run your functions in response to various events in the Google Cloud environment or via HTTP requests.
1. HTTP Triggers:
• HTTP triggers allow your Cloud Function to be invoked via standard HTTP requests. These are useful for building APIs, webhooks, and other services that are accessible over the internet or within your internal network.
2. Cloud Pub/Sub Triggers:
• Cloud Functions can be triggered by messages published to Cloud Pub/Sub topics. This is useful for asynchronous event-driven architectures and integrating with systems that publish events to Pub/Sub.
3. Cloud Storage Triggers:
• Functions can respond to changes in Google Cloud Storage, such as creating, deleting, or updating objects. This is helpful for processing uploaded files, data backups, and more.
4. Firestore Triggers:
• These triggers allow functions to execute in response to changes in Google Cloud Firestore data, including document creation, updates, and deletions. They are useful for syncing Firestore data with other data stores, or for handling real-time data updates.
5. Firebase Realtime Database Triggers:
• Cloud Functions can be triggered by changes in Firebase Realtime Database. This is similar to Firestore triggers but specific to Firebase's Realtime Database service.
6. Firebase Authentication Triggers:
• Functions can react to Firebase Authentication events, such as user creation, deletion, or attribute updates. These triggers are useful for custom user management workflows and integration with external systems.
7. Google Analytics for Firebase Triggers:
• These triggers enable functions to respond to Analytics events collected by Firebase, useful for custom event processing and integrations.
8. Scheduled (Cron) Triggers:
• Cloud Scheduler can be used to trigger functions on a time-based schedule (cron). This is ideal for running batch jobs, regular clean-ups, or other scheduled tasks.
Question asks:
You want to deploy this code snippet. What should you do?
To me, none of the answers is relevant to DEPLOYMENT - they all are about how you get the trigger to run ...
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
ESP_SAP
Highly Voted 4Â years agofrancisco_guerra
Highly Voted 4Â years agoSSPC
4Â years agoAle1973
3Â years, 12Â months agoCynthia2023
Most Recent 8Â months agoCynthia2023
8Â months agoCynthia2023
8Â months agoscanner2
12Â months agoCaptain1212
12Â months agoAngel_99
2Â years agoAzureDP900
2Â years, 2Â months agoarvsrv
2Â years, 7Â months agoSurat
2Â years, 7Â months agoalaahakim
2Â years, 9Â months agovamgcp
2Â years, 11Â months agoZimcruza
3Â years, 2Â months agoGoCloud
3Â years, 5Â months agomarialix87
3Â years, 5Â months agoGCP_Student1
3Â years, 5Â months agolutoa
3Â years, 6Â months agovictory108
3Â years, 7Â months ago