Skip to content

Instantly share code, notes, and snippets.

@vykhand
Created June 7, 2018 17:20
Show Gist options
  • Save vykhand/c332fd30a26ace484dfd1bf84a844abc to your computer and use it in GitHub Desktop.
Save vykhand/c332fd30a26ace484dfd1bf84a844abc to your computer and use it in GitHub Desktop.
Send message to Azure Event Hub from Python
from azure.servicebus import ServiceBusService
api_key = {"namespace":"",
"policy_name":"",
"hub_name":"",
"policy_secret":""}
sbs = ServiceBusService(api_key["namespace"], shared_access_key_name=api_key["policy_name"], shared_access_key_value=api_key["policy_secret"])
for i in range(1000):
sbs.send_event(api_key["hub_name"], '{ "DeviceId":"Hello", "Temperature":"10.0" }')
print("sending message " + str(i))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment