Unable to import the eventgrid modules in my VS Code, I have added all the modules in requirement.txt and pip installed from my cmd.
Also, below is the python function which I am looking and trying with:
def publish_event():
# authenticate client
credential = AzureKeyCredential(key)
client = EventGridPublisherClient(endpoint, credential)
custom_schema_event = {
"customSubject": "sample",
"customEventType": "sample.event",
"customDataVersion": "2.0",
"customId": uuid.uuid4(),
"customEventTime": dt.datetime.now(UTC()).isoformat(),
"customData": "sample data"
}
# publish events
for _ in range(3):
event_list = [] # list of events to publish
# create events and append to list
for j in range(randint(1, 3)):
event_list.append(custom_schema_event)
# publish list of events
client.send(event_list)
print("Batch of size {} published".format(len(event_list)))
time.sleep(randint(1, 5))
if name == '__main__':
publish_event()
I am not sure whether this is the correct method to achieve this, looking for better ways to solve the module issue and to publish events.
Help would be appreciated !