fixed 'async with outside async func' syntax error in EH async auth with conn str sample
An example to show authentication using a connection string obtained via the Azure Portal, or the Azure CLI toolkit.
"""
+import asyncio
import os
from azure.eventhub.aio import EventHubConsumerClient
CONNECTION_STR = os.environ["EVENT_HUB_CONN_STR"]
EVENTHUB_NAME = os.environ['EVENT_HUB_NAME']
+async def main():
consumer_client = EventHubConsumerClient.from_connection_string(
conn_str=CONNECTION_STR,
consumer_group='$Default',
eventhub_name=EVENTHUB_NAME,
)
-
async with consumer_client:
pass # consumer_client is now ready to be used.
+
+if __name__ == '__main__':
+ loop = asyncio.get_event_loop()
+ loop.run_until_complete(main())
