In my previous post, I walked you through on how to Install Python Azure SDK on Intel Galileo.
Let’s now put that Python SDK into some work and post something to an Azure Service Bus Queue.
It’s really rather straight forward:
from azure.servicebus import ServiceBusService, Message, Queue
from azure.storage import QueueService
service_namespace = '<YOURSERVICENAME>'
key_name = 'MyIoTDevices'
key_value = '<YOURKEY>'
queue_name = 'mytestqueue'
message = Message(base64.b64encode('Hello World'))
sbs = ServiceBusService(service_namespace,
The only thing is to Base64 encode your string to be compatible with the other Azure SDK’s, in case you want compatibility with WIndows/Android/iOS etc.
But before we run this, you would need to set the on board clock on the Intel Galilelo, otherwise you will get this error:
azure.WindowsAzureError: Unknown error (Unauthorized)
<Error><Code>401</Code><Detail>ExpiredToken: . TrackingId:12341234-1234-1234-1234-123412341234_G18,TimeStamp:10/27/2014 5:06:24 PM</Detail></Error>
So, they easiest way is to synchronise the clock against a time server:
rdate -s wwv.nist.gov
You will need to do this every time after you have shut down the board, since the clock is not battery backed up. So it might be a good idea to put this in a script and have it run at startup.
There you have it.