Reputation: 21749
I have successfully configured my Azure IoT Dev Kit MXChip and I am able to send the data to the IoT Hub. I have also created a logic app with a router in it to receive a mail when the temperature is more than expected and a SQL server to save the Stream Analytics Job data. Basically, I followed the tutorial and till this point, everything was working fine, now I am just creating a simulator device where I can simulate events as mentioned in this tutorial. But whenever I run the application, I am always getting an error as below.
Microsoft.Azure.Devices.Client.Exceptions.UnauthorizedException: 'CONNECT failed: RefusedNotAuthorized'
I am not sure what I am missing here though I understand it is an authentication issue, and I have already changed my Hub Uri and device key as mentioned in the tutorial.
private readonly static string s_iotHubUri = "";
// This is the primary key for the device. This is in the portal.
// Find your IoT hub in the portal > IoT devices > select your device > copy the key.
private readonly static string s_deviceKey = "";
Upvotes: -1
Views: 1948
Reputation: 21749
I just figured out what is making this error. I thought the device id we can use here is just a dummy one as it is not mentioned in the tutorial, but not. So, I had two option,
I just created a new test-device in the Hub.
private readonly static string s_myDeviceId = "test-device";
private readonly static string s_iotHubUri = "youriothubname.azure-devices.net";
private readonly static string s_deviceKey = "devicekey";
After doing that changes, everything was working fine as expected.
Upvotes: 0