1

I want to send messages to the Azure IoT Hub using the MQTT protocol. I followed this video and managed to connect my Linux-based device (a Raspberry Pi) to the IoT Hub.

As instructed in the aforementioned tutorial, I used the Azure IoT Explorer to generate a connection string with SAS token.

However I noticed that the user is prompted to define an expiration for the SAS token, given in minutes (second box from the bottom in the image below): enter image description here

I would like to have my device send messages to Azure over extended periods of time (i.e. several weeks). How can I specify such a long duration?

I tried passing 20,000 minutes (~ 1 month) as an argument. I was able to generate a seemingly valid SAS token connection string, but then again, if I pass an aberrant value (e.g. 0 or -1) I am still able to generate a token. Although my token is currently working, I am concerned that it will expire after a default "maximum expiration duration".

So what is the maximum duration that can be passed in the Expiration (minutes) field?

EDIT: according to this SO post, the maximum expiration date for the SAS token is 365 days:

You can specify the expiration date for a SAS token, I think the maximum is 365 days, but forever is not a possibility.

1 Answer 1

0
+50

Technically there is no limit according to various documentation I've looked at.

There may be some limitations imposed by the UI you are using (typically 1 year as you've seen), but if you generate the token with the CLI or programmatically there should be no upper limit within reason (a large enough number could exceed the data capacity of various things, but a hundred years is reported to work fine).

Another limit is one imposed by security best practices, but I don't believe that's within the scope of this question.

1
  • Thank you for your answer Benjamin. I agree with you: keeping the SAS token unchanged for an extended period of time is not a good practice from a cybersecurity perspective... But that's another story!
    – Sheldon
    Nov 11, 2021 at 18:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.