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:
- Azure CLI: https://learn.microsoft.com/en-us/cli/azure/iot/hub?view=azure-cli-latest#az-iot-hub-generate-sas-token
- Azure IoT tools for Visual Studio Code: https://marketplace.visualstudio.com/items?itemName=vsciot-vscode.azure-iot-tools
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
Have a look at the Azure IoT Explorer.
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 theresourceUri
and don’t include apolicyName
.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.
It is possible to generate SAS tokens in the Azure portal:
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.