1
votes

I am trying to create an IoT device at IOT HUB using python based azure-iot sdk.

At present, I can create an IOT device(using AZ CLI or through dashboard) and can link it with my soft client(using connection string).

But would like to implement the creation of IoT device logic programmatically, for which, I found that this could be done though Azure Rest API:

https://docs.microsoft.com/en-us/rest/api/iothub/service/createorupdatedevice

One of the requirement is authentication through SAS. I further investigated to find out that the azure IoT sdk (for .net) exposes SharedAccessSignatureBuilder that could help in this regard:

https://docs.microsoft.com/en-us/dotnet/api/microsoft.azure.devices.common.security.sharedaccesssignaturebuilder?view=azure-dotnet

My questions:

  1. Am I going in the correct direction to solve it, or is there any other way around.
  2. Do we have any SharedAccessSignatureBuilder for Python or Java? I checked but couldn't find one.
1

1 Answers

0
votes

If you look for the Azure IoT SDK for Python sample code on GitHub there is a sample Python script that creates a device using the class IoTHubRegistryManager.

If you are connecting to your Azure IoT hub using the MS IoT Python SDK then you will not need to build your own SAS token. The SDK will take care of that for you. There isn't a Python implementation though since it is a wrapper around the C SDK. I don't know if Java SDK has an implementation. It must do it somehow but I am not familiar with the code. It may use a third party package.