Generate a SAS token
Generate a SAS token with the Device Explorer application or Azure IoT explorer
application.
TIP:
Use certificates for authentication to ensure security
and efficiency.
Prerequisites
From the Azure portal, obtain the
IoT Hub connection string
. For more information, see https://devblogs.microsoft.com/iotdev/understand-different-connection-strings-in-azure-iot-hub/.- To generate a SAS token
- To generate a SAS token with the Device Explorer application:
- Download, install, and open the Device Explorer application from https://github.com/Azure/azure-iot-sdk-csharp/releases.
- In the relative field, insert theIoT Hub connection string.
- SelectUpdate.
- In theManagementtab, if the device is not created, selectCreate.
- SelectSAS Token.
- Select the device.
- Specify the token validity period by setting theTTL (Days)option.IMPORTANT: Consider the token validity period. If the token expires, the connection stops. To restore the connection, you need to regenerate the SAS token and deploy the project to the device again.
- SelectGenerate.
- To generate a SAS token with Azure IoT explorer application:
- Download, install, and open Azure IoT explorer application from https://github.com/Azure/azure-iot-explorer/releases.
- In the suggested field, insert theIoT Hub connection string.
- SelectConnect.
- If the device is not created, selectNew.
- Select the device.
- In theConnection string with SAS tokentab, fromPrimary Key, selectSymmetric key.
- Determine the token expiration period (minutes) by setting theSet Expirationoption.
- SelectGenerate.
Provide Feedback