1
votes

Is there a way to send data to a device in Azure IoT Hub using a shared key without first generating a SAS token? The reason I am trying to do this is because I want to send events via a web hook without writing code for it. The device is connected to our system and we're trying to use our web hooks functionality which can relay an event to a HTTP endpoint with preconfigured headers and format but it can't execute the code to get a temporary SAS token.

Alternatively can I make a SAS token that never expires?

1
For your case, I do recommend to use a serverless integrator to the Azure IoT Hub service-facing endpoint such as either the Api Management service or Azure Function. Basically, there are two options for sending a data to the device, such as C2D messaging (AMQP) or invoking a direct method on the device (Https). Note, that the direct method requires to use a specific payload schema, therefore you should use anyway recommended integrator.Roman Kiss
"Alternatively can I make a SAS token that never expires?" I think you always need to give an expiry date but this can also be years in the futuresilent
@RomanKiss I considered using an Azure function to generate the token but I'd like to skip that if possible. I am also considering adding a special type of web hook on our end to handle IoT hub specifically. We want to minimize setup for future customers so we want to avoid the Azure functionStilgar
@silent I can't seem to find a limit for that. I wonder if I can assume that 20 years expiry will work.Stilgar

1 Answers

0
votes

Ended up using Azure IoT Central + the Azure IoT Central Bridge. The IoT Bridge is an Azure function where you put some JS code to convert your message to a format that IoT Central understands and then it deals with the tokens and eventual device registration. This is not an exact answer to the question since IoT Central is not exactly IoT Hub (it is a portal over it) but it turns out it works well enough for our case. Also I think the codebase of the IoT Bridge can be used with the IoT Hub if one wants to dig enough through it. Maybe this solution can serve someone else.