I have already written the code for google cloud http function however now I also wants to trigger the same function when the message published on pubsub.
So how do I invoke same cloud function from Http and ICloundEventFunction(fron pubsub)?
You can use a 2nd generation Cloud Function and create HTTP and PubSub triggers in one Cloud Function.
You can find details about it from this link: https://cloud.google.com/blog/products/serverless/cloud-functions-2nd-generation-now-generally-available
You can directly trigger a Cloud function on push mode with a Pub Sub topic:
https://cloud.google.com/functions/docs/calling/pubsub
This link explains well how to deploy a Cloud Function that listen a topic:
gcloud functions deploy YOUR_FUNCTION_NAME \
--trigger-topic=YOUR_PUBSUB_TOPIC \
[--retry] \
...
The cloud function is triggered when a message is published on the topic.
In Cloud Functions (2nd gen), Pub/Sub triggers are implemented as a particular type of Eventarc trigger.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.