-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
89dda0c
commit ba6b085
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |