How to connect Azure IoT Device Telemetry Simulator with Docker

Alexander Mamani Yucra 0 Reputation points
2025-04-05T12:07:26.28+00:00

I tried to carried out a Telemetry Simulation with Azure IoT Device Telemetry Simulator but I got this error, On the documentation talk about executed with docker, I replace the SharedAccessKey with my Primary and Secondary Key from my IoT Hub Device and "HostName" with IoT hub name (iotmamani)

If someone has dealt with this problem, I would be happy to receive comments

User's image

docker run -it -e "IotHubConnectionString=HostName=your-iothub-name.azure-devices.net;SharedAccessKeyName=device;SharedAccessKey=your-iothub-key" mcr.microsoft.com/oss/azure-samples/azureiot-telemetrysimulator

Doc:
https://learn.microsoft.com/en-us/samples/azure-samples/iot-telemetry-simulator/azure-iot-device-telemetry-simulator/

Starting simulator v1.1

Device count = 1

Device prefix = sim

Device 0-last = (sim000001-sim000001)

Device index = 1

Message count = 100

Interval = 1000ms

Template = Template: { "deviceId": "$.DeviceId", "rand_int": $.Temp, "rand_double": $.DoubleValue, "Ticks": $.Ticks, "Counter": $.Counter, "time": "$.Time" }

Header =

========================================================================================================================

Microsoft.Azure.Devices.Client.Exceptions.UnauthorizedException: error(condition:amqp:unauthorized-access,description:Put token failed. status-code: 401, status-description: The specified SAS token has an invalid signature. It does not match either the primary or secondary key..)

---> Microsoft.Azure.Amqp.AmqpException: Put token failed. status-code: 401, status-description: The specified SAS token has an invalid signature. It does not match either the primary or secondary key..

at Microsoft.Azure.Amqp.ExceptionDispatcher.Throw(Exception exception)

at Microsoft.Azure.Amqp.AsyncResult.EndTAsyncResult

Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
1,258 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Sander van de Velde | MVP 36,131 Reputation points MVP
    2025-04-06T16:12:38.3366667+00:00

    Hello @Alexander Mamani Yucra,

    welcome to this moderated Azure community forum.

    I tried it myself using Docker Desktop in Windows.

    As connection string, you need to provide a IoT Hub connectionstring, not connectionstring of a device (it will try to create one device name sim000001 in this case).

    Iot Hub connection string. "Device" our "Iot Hub owner" scopes are good. Example: HostName=your-iothub-name.azure-devices.net;SharedAccessKeyName=device;SharedAccessKey=your-iothub-key

    Unfortunately, this did not for me too, I got an "errorCode":401002,"message":"Unauthorized access"" too.

    You can create an issue at https://github.com/Azure/iotedge so the Azure IoT team can take a look.

    If you are in a hurry, just create a test device client application using one of the Device SDK samples.


    If the response helped, do "Accept Answer". If it doesn't work, please let us know the progress. All community members with similar issues will benefit by doing so. Your contribution is highly appreciated.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.