Skip to content

Commit

Permalink
PythonToEventHub
Browse files Browse the repository at this point in the history
  • Loading branch information
rawatsudhir committed Jul 14, 2015
1 parent 89dda0c commit ba6b085
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions PythonToEventHub
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#import random because using one of the functions in code
import random
from azure.servicebus import ServiceBusService

# SharedAccessKeyName from Azure Portal
key_name ='RootManageSharedAccessKey'

# SharedAccessKey from Azure Portal
key_value=''

# Pointing to Microsoft Azure Service Bus
sbs = ServiceBusService('SERVICE_BUS_NAME', shared_access_key_name=key_name, shared_access_key_value=key_value)

# Event Hub Creation
sbs.create_event_hub('hubcreationfromlinux')

# Some randomg values
devicecounts = 5
eventcounts = 1000

for eventcount in range (1, eventcounts) :
deviceId = "dev-" + str(random.randrange (1, devicecounts))
temperature = str(float("{0:.2f}".format(random.uniform (0,50))))
sbs.send_event('hubcreationfromlinux', '{ "DeviceId":"' + deviceId + '", "Temperature":"' + temperature +'"}')
print "DeviceId : " + deviceId + " Temperature : " + temperature

0 comments on commit ba6b085

Please sign in to comment.