Zum testen ob die Nachrichten/Events wirklich im IoT Hub ankommen.
from azure.eventhub import EventHubConsumerClient# Connection string for the IoT Hub-compatible endpointCONNECTION_STR = "Endpoint=sb://iothub-ns-iothub0caf-24940406-8dd0ed6476.servicebus.windows.net/;SharedAccessKeyName=iothubowner;SharedAccessKey=dFWBWCZaSwZqwX9JsRwwfLvLErL3SuxUGQZhfBOSKsY=;EntityPath=iothub0caf679ca31b41b1b4"
EVENTHUB_NAME ="iothub0caf679ca31b41b1b4"# Consumer group to use for the consumer clientCONSUMER_GROUP ="$Default"# Define callback function for handling received eventsdefon_event(partition_context,event):print("Received event from partition: {}".format(partition_context.partition_id))print(event.body_as_str())# Create an instance of the EventHubConsumerClientclient = EventHubConsumerClient.from_connection_string( conn_str=CONNECTION_STR, consumer_group=CONSUMER_GROUP, eventhub_name=EVENTHUB_NAME)# Create a new event hub consumer for each partition and start receiving eventswith client:for partition in client.get_partition_ids(): client.receive(on_event=on_event, partition_id=partition)