예제 #1
0
 public static Task <EdgeDevice> CreateIdentityAsync(
     string deviceId,
     IotHub iotHub,
     CancellationToken token)
 {
     return(Profiler.Run(
                $"Creating edge device '{deviceId}' on hub '{iotHub.Hostname}'",
                async() =>
     {
         Device device = await iotHub.CreateEdgeDeviceIdentityAsync(deviceId, token);
         return new EdgeDevice(device, true, iotHub);
     }));
 }
예제 #2
0
        public static Task <EdgeDevice> CreateIdentityAsync(
            string deviceId,
            IotHub iotHub,
            AuthenticationType authType,
            X509Thumbprint x509Thumbprint,
            CancellationToken token)
        {
            if (authType == AuthenticationType.SelfSigned && x509Thumbprint == null)
            {
                throw new ArgumentException("A device created with self-signed mechanism must provide an x509 thumbprint.");
            }

            return(Profiler.Run(
                       async() =>
            {
                Device device = await iotHub.CreateEdgeDeviceIdentityAsync(deviceId, authType, x509Thumbprint, token);
                return new EdgeDevice(device, true, iotHub);
            },
                       "Created edge device '{Device}' on hub '{IotHub}'",
                       deviceId,
                       iotHub.Hostname));
        }