Beispiel #1
0
        public async Task <TrafficSegmentConfiguration> GetConfiguration()
        {
            _deviceConnectionString = ConfigurationCache.GetValue("deviceConnectionString");
            _deviceClient           = DeviceClient.CreateFromConnectionString(_deviceConnectionString);
            await _deviceClient.SetDesiredPropertyUpdateCallbackAsync(TwinPropertiesChanged, null);

            var iotHubOwnerConnectionString = _configurationReader.GetConfigValue <string>("IOTHUB_OWNER_CONNECTIONSTRING", true);

            try
            {
                var twin = await _deviceClient.GetTwinAsync();

                return(GetConfigurationFromTwin(twin.Properties.Desired));
            }
            catch (Exception e)
            {
                _logger.Error(e, $"An error occurred when trying read device on IoT Hub: {e.Message}");
                throw;
            }
        }