IoTHub and Device Connection Strings

Damir Dobric Posts

Next talks:

 

    

Follow me on Twitter: #ddobric



 

 

Archives


IoTHub introduce new kind of connection string called Device Connection string. To create device client instance you can do following:

var client = DeviceClient.Create(“HUBNAME.azure-devices.net”,
new DeviceAuthenticationWithRegistrySymmetricKey("DEVNAME"
, “uck7p18***pDTIA2”));


However, for practical reasons Device Connection String might more often be used. Here is one example:
HostName=HUBNAME.azure-devices.net;DeviceId=DEVICENAME;SharedAccessKey=uck7p18***pDTIA2

Following example shows how the string and client can be built from key and device name:

string connStr = String.Format("HostName={0}.azure-devices.net;DeviceId={1};SharedAccessKey={2}", "daenethub", "D001", m_DeviceKey);

 

var client = DeviceClient.CreateFromConnectionString(connStr);


Posted Oct 13 2015, 04:06 PM by Damir Dobric
developers.de is a .Net Community Blog powered by daenet GmbH.