public SensorTelemetry(ILogger <SensorTelemetry> logger, IOptions <TelemetryConfig> options) { if (options.Value.ServiceEnabled) { Publisher = TelemetryPublisherFactory.Create(options.Value.Publisher, options.Value.ConnectionString, "NucuCar.Sensors", logger); } else { Publisher = null; } }
public static async Task RunAzurePublisherTelemetryTest(AzureTelemetryPublishOptions opts) { var logger = LoggerFactory.Create(builder => { builder.AddConsole(); }) .CreateLogger <AzureTelemetryPublishCmd>(); var telemetryPublisher = TelemetryPublisherFactory.Create(TelemetryPublisherType.Azure, opts.PublisherConnectionString, "NucuCar.TestClient", logger); var anonymousTelemeter = new DummyTelemeter( JsonConvert.DeserializeObject <Dictionary <string, object> >(opts.PublisherJsonMessage)); logger.LogInformation($"Publishing message: {opts.PublisherJsonMessage}"); telemetryPublisher.RegisterTelemeter(anonymousTelemeter); await telemetryPublisher.PublishAsync(CancellationToken.None); }