0

I want to write messages from a service bus queue to a topic in GCP Pub Sub. I hve a azure function that is triggered by incoming queue message.

I then write the message to the Pub Sub Topic. I understand there is more to do to access GCP resources.

What I'm first failing at is even getting azure to recognise the google.cloud module.

Can anyone help with this?

FailureException: ModuleNotFoundError: No module named 'google.cloud'.

rest of my code for reference...

import logging
import json
import azure.functions as func
from google.cloud import pubsub_v1
from google.oauth2 import service_account

CREDENTIALS = service_account.Credentials.from_service_account_file(
    './service_account.json')


PUBLISHER = pubsub_v1.PublisherClient(credentials=CREDENTIALS)

PROJECT_ID = 'polestar-poc'


def publish_to_gcp(topic, msg):
    PUBLISHER.create_topic(PROJECT_ID, name=topic)
    PUBLISHER.publish(topic, msg)


def main(msg: func.ServiceBusMessage):
    data = json.loads(msg.get_body())
    topic_name = (data['topic'])
    publish_to_gcp(topic_name, data)
Harvey
  • 668
  • 2
  • 7
  • 15

0 Answers0