TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Manikandan Murugesan
133
14.2k
430.7k
How to create a device identity for IotHub in VS-17
Jun 14 2017 10:25 PM
I am beginner of IOT and i learning to creating the app with IotHub by seeing the tutorial from this link:
https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-csharp-csharp-getstarted
i created the IotHub using Azure but I can't create an identity of my device.
Here's my code :
using
System;
using
System.Threading.Tasks;
using
Microsoft.Azure.Devices;
using
Microsoft.Azure.Devices.Common.Exceptions;
namespace
DeviceIdentity
{
class
Program
{
static
RegistryManager Registrymanager;
static
string
connectionString =
"{iot hub connection string}"
;
private
static
async Task AddDeviceAsync()
{
string
deviceId =
"myFirstdevice"
;
Device device;
try
{
device = await Registrymanager.AddDeviceAsync(
new
Device(deviceId));
}
catch
(DeviceAlreadyExistsException)
{
device = await Registrymanager.GetDeviceAsync(deviceId);
}
Console.WriteLine(
"Generated device key: {0}"
, device.Authentication.SymmetricKey.PrimaryKey);
}
static
void
Main(
string
args[])
{
Registrymanager =RegistryManager.CreateFromConnectionString(connectionString);
AddDeviceAsync().Wait();
Console.ReadLine();
}
}
}
Reply
Answers (
1
)
How to upload bigdata to cloud
Install Azure Cli Error