I have wrote a simple code to print data and context from a pubsub trigger cloud function.
def main(event, context):
"""Background Cloud Function to be triggered by Pub/Sub.
Args:
event (dict): The dictionary with data specific to this type of
event. The data field contains the PubsubMessage message. The
attributes field will contain custom attributes if there are any.
context (google.cloud.functions.Context): The Cloud Functions event
metadata. The event_id field contains the Pub/Sub message ID. The
timestamp field contains the publish time.
"""
import base64
print("""This Function was triggered by messageId {} published at {}
""".format(context.event_id, context.timestamp))
if 'data' in event:
name = base64.b64decode(event['data']).decode('utf-8')
else:
name = 'World'
print('Hello {}!'.format(name))
Cloud function is deployed successfully but whenever I publish a message to the trigger topic in logs I cannot see any function execution statement.
I have already verified that I am calling main function only and publishing to a right pubsub topic.
I cannot see any error statement so I am not able to debug.
Any Suggestion will be helpful