skip to Main Content

I am going through the following article:

https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-dev-guide-sas?tabs=node#sas-tokens

… and I understand that I have the following options to generate a per device SAS token:

Other than above two options, are there any other way(s) to generate per-device SAS connection strings?

Is there any way to generate per-device SAS tokens in Azure Portal?

4

Answers


  1. Other than above two options, are there any other way(s) to generate per-device SAS connection strings?

    Next to Roman’s suggestion for Azure IoT Explorer, you can also write your own SAS token generator. The documentation you linked also code samples in four programming languages; you can use those to create SAS tokens for a device as well. Use {hub name}.azure-devices.net/devices/{device name} for the resourceUri and don’t include a policyName.

    Is there any way to generate per-device SAS tokens in Azure Portal?

    No (I mean, you could use the Cloud Shell and use the Azure CLI in the Portal, but I don’t think that’s what you’re asking). There is no visual interface for this in the Azure Portal.

    Login or Signup to reply.
  2. It is possible to generate SAS tokens in the Azure portal:

    • In your IoT hub, navigate to Devices in the Device Management section.
    • Either add a new device or select an existing one.
    • You can view the SAS keys and connection strings for the device.
    • The Manage keys menu lets you regenerate and swap keys.

    enter image description here

    Login or Signup to reply.
  3. Typically, you would generate the SAS token on the device, at least in a production environment due to the SAS token having a limited lifetime. Once that expires you would need to go back and give it a new one.
    You don’t mention what language you might be using but, if you are using C you will notice that the examples cited above do not include that language. I have a C demo here though: https://github.com/markrad/IoTSASTokenGenerate should it be of interest to you.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search