diff --git a/deploy/templates/default-azuredeploy-webjobs.json b/deploy/templates/default-azuredeploy-webjobs.json index 36553445..a645765f 100644 --- a/deploy/templates/default-azuredeploy-webjobs.json +++ b/deploy/templates/default-azuredeploy-webjobs.json @@ -611,18 +611,18 @@ "EventBatching:MaxEvents": "[parameters('JobMaxEvents')]", "Checkpoint:BlobPrefix": "", "Checkpoint:CheckpointBatchCount": 5, - "CheckpointStorage:ServiceManagedIdentityAuth": true, + "CheckpointStorage:AuthenticationType": "ManagedIdentity", "CheckpointStorage:BlobStorageContainerUri": "[variables('checkpoint_storage_uri')]", - "TemplateStorage:ServiceManagedIdentityAuth": true, + "TemplateStorage:AuthenticationType": "ManagedIdentity", "TemplateStorage:BlobStorageContainerUri": "[variables('template_storage_uri')]", "InputEventHub:EventHubNamespaceFQDN": "[variables('eventhub_fqdn')]", "InputEventHub:EventHubConsumerGroup": "$Default", "InputEventHub:EventHubName": "devicedata", - "InputEventHub:ServiceManagedIdentityAuth": true, + "InputEventHub:AuthenticationType": "ManagedIdentity", "NormalizationEventHub:EventHubNamespaceFQDN": "[variables('eventhub_fqdn')]", "NormalizationEventHub:EventHubConsumerGroup": "$Default", "NormalizationEventHub:EventHubName": "normalizeddata", - "NormalizationEventHub:ServiceManagedIdentityAuth": true, + "NormalizationEventHub:AuthenticationType": "ManagedIdentity", "FhirVersion": "[parameters('FhirVersion')]", "FhirService:Url": "[concat('@Microsoft.KeyVault(SecretUri=', reference(resourceId('Microsoft.KeyVault/vaults/secrets', variables('key_vault_name'),'fhirserver-url'), '2018-02-14').secretUriWithVersion, ')')]", "FhirService:Authority": "[concat('@Microsoft.KeyVault(SecretUri=', reference(resourceId('Microsoft.KeyVault/vaults/secrets', variables('key_vault_name'),'fhirserver-authority'), '2018-02-14').secretUriWithVersion, ')')]", diff --git a/src/console/Normalize/Processor.cs b/src/console/Normalize/Processor.cs index 0303e819..a98f00c3 100644 --- a/src/console/Normalize/Processor.cs +++ b/src/console/Normalize/Processor.cs @@ -25,15 +25,18 @@ public class Processor : IEventConsumer private ITemplateManager _templateManager; private ITelemetryLogger _logger; private IConfiguration _env; + private IAsyncCollector _collector; public Processor( [Blob("template/%Template:DeviceContent%", FileAccess.Read)] string templateDefinition, ITemplateManager templateManager, + IAsyncCollector collector, IConfiguration configuration, ITelemetryLogger logger) { _templateDefinition = templateDefinition; _templateManager = templateManager; + _collector = collector; _logger = logger; _env = configuration; } @@ -70,21 +73,8 @@ public async Task ConsumeAsync(IEnumerable events) }); var dataNormalizationService = new MeasurementEventNormalizationService(_logger, template); - - var collector = CreateCollector(); - await dataNormalizationService.ProcessAsync(eventHubEvents, collector).ConfigureAwait(false); - } - - private IAsyncCollector CreateCollector() - { - var eventHubProducerOptions = new EventProducerClientOptions(); - _env.GetSection("NormalizationEventHub").Bind(eventHubProducerOptions); - - var eventHubProducerFactory = new EventProducerClientFactory(); - var eventHubProducerClient = eventHubProducerFactory.GetEventHubProducerClient(eventHubProducerOptions); - - return new MeasurementToEventMessageAsyncCollector(new EventHubProducerService(eventHubProducerClient)); + await dataNormalizationService.ProcessAsync(eventHubEvents, _collector).ConfigureAwait(false); } } } diff --git a/src/console/Startup.cs b/src/console/Startup.cs index 84503443..04a295b8 100644 --- a/src/console/Startup.cs +++ b/src/console/Startup.cs @@ -6,9 +6,11 @@ using Azure.Messaging.EventHubs; using Microsoft.ApplicationInsights; using Microsoft.ApplicationInsights.Extensibility; +using Microsoft.Azure.WebJobs; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Health.Common.Storage; +using Microsoft.Health.Events.Common; using Microsoft.Health.Events.EventCheckpointing; using Microsoft.Health.Events.EventConsumers; using Microsoft.Health.Events.EventConsumers.Service; @@ -16,6 +18,7 @@ using Microsoft.Health.Events.EventProducers; using Microsoft.Health.Events.Repository; using Microsoft.Health.Fhir.Ingest.Console.Template; +using Microsoft.Health.Fhir.Ingest.Data; using Microsoft.Health.Fhir.Ingest.Service; using Microsoft.Health.Logging.Telemetry; using System; @@ -25,8 +28,8 @@ namespace Microsoft.Health.Fhir.Ingest.Console { public class Startup { - private const string _deviceDataEventHubType = ApplicationType.Normalization; - private const string _normalizedDataEventHubType = ApplicationType.MeasurementToFhir; + private const string _normalizationAppType = ApplicationType.Normalization; + private const string _measurementToFhirAppType = ApplicationType.MeasurementToFhir; public Startup(IConfiguration configuration) { Configuration = configuration; @@ -67,13 +70,14 @@ public virtual List ResolveEventConsumers(IServiceProvider servi var templateManager = serviceProvider.GetRequiredService(); var logger = serviceProvider.GetRequiredService(); - if (applicationType == _deviceDataEventHubType) + if (applicationType == _normalizationAppType) { template = Configuration.GetSection("Template:DeviceContent").Value; - var deviceDataNormalization = new Normalize.Processor(template, templateManager, Configuration, logger); + var collector = ResolveEventCollector(serviceProvider); + var deviceDataNormalization = new Normalize.Processor(template, templateManager, collector, Configuration, logger); eventConsumers.Add(deviceDataNormalization); } - else if (applicationType == _normalizedDataEventHubType) + else if (applicationType == _measurementToFhirAppType) { template = Configuration.GetSection("Template:FhirMapping").Value; var importService = serviceProvider.GetRequiredService(); @@ -113,16 +117,27 @@ public virtual IEventConsumerService ResolveEventConsumerService(IServiceProvide return new EventConsumerService(eventConsumers, logger); } + public virtual IAsyncCollector ResolveEventCollector(IServiceProvider serviceProvider) + { + var eventHubProducerOptions = new EventHubClientOptions(); + Configuration.GetSection("NormalizationEventHub").Bind(eventHubProducerOptions); + + var eventHubProducerFactory = serviceProvider.GetRequiredService(); + var eventHubProducerClient = eventHubProducerFactory.GetEventHubProducerClient(eventHubProducerOptions); + + return new MeasurementToEventMessageAsyncCollector(new EventHubProducerService(eventHubProducerClient)); + } + public virtual EventProcessorClient ResolveEventProcessorClient(IServiceProvider serviceProvider) { - var eventProcessorOptions = new EventProcessorClientFactoryOptions(); + var eventProcessorOptions = new EventHubClientOptions(); var applicationType = GetConsoleApplicationType(); - if (applicationType == _deviceDataEventHubType) + if (applicationType == _normalizationAppType) { Configuration.GetSection("InputEventHub").Bind(eventProcessorOptions); } - else if (applicationType == _normalizedDataEventHubType) + else if (applicationType == _measurementToFhirAppType) { Configuration.GetSection("NormalizationEventHub").Bind(eventProcessorOptions); } @@ -131,7 +146,7 @@ public virtual EventProcessorClient ResolveEventProcessorClient(IServiceProvider throw new Exception($"Unable to determine event processor options from application type {applicationType}"); } - var eventProcessorClientFactory = new EventProcessorClientFactory(); + var eventProcessorClientFactory = serviceProvider.GetRequiredService(); var eventProcessorClientOptions = new EventProcessorClientOptions(); eventProcessorClientOptions.MaximumWaitTime = TimeSpan.FromSeconds(60); diff --git a/src/console/appsettings.json b/src/console/appsettings.json index 4b03485e..dfdb16b7 100644 --- a/src/console/appsettings.json +++ b/src/console/appsettings.json @@ -4,9 +4,9 @@ "EventBatching:MaxEvents": 300, "Checkpoint:BlobPrefix": "", "Checkpoint:CheckpointBatchCount": 5, - "CheckpointStorage:ServiceManagedIdentityAuth": true, + "CheckpointStorage:AuthenticationType": "ManagedIdentity", "CheckpointStorage:BlobStorageContainerUri": "", - "TemplateStorage:ServiceManagedIdentityAuth": true, + "TemplateStorage:AuthenticationType": "ManagedIdentity", "TemplateStorage:BlobStorageContainerUri": "", "Console:ApplicationType": "", "FhirService:Authority": "", @@ -14,14 +14,14 @@ "FhirService:ClientSecret": "", "FhirService:Resource": "", "FhirService:Url": "", + "InputEventHub:AuthenticationType": "ManagedIdentity", "InputEventHub:EventHubNamespaceFQDN": "", "InputEventHub:EventHubConsumerGroup": "$Default", "InputEventHub:EventHubName": "devicedata", - "InputEventHub:ServiceManagedIdentityAuth": true, + "NormalizationEventHub:AuthenticationType": "ManagedIdentity", "NormalizationEventHub:EventHubNamespaceFQDN": "", "NormalizationEventHub:EventHubConsumerGroup": "$Default", "NormalizationEventHub:EventHubName": "normalizeddata", - "NormalizationEventHub:ServiceManagedIdentityAuth": true, "ResourceIdentity:ResourceIdentityServiceType": "Create", "ResourceIdentity:DefaultDeviceIdentifierSystem": "", "Template:DeviceContent": "devicecontent.json", diff --git a/src/lib/Microsoft.Health.Common/Storage/BlobContainerClientFactory.cs b/src/lib/Microsoft.Health.Common/Storage/BlobContainerClientFactory.cs index 142698c9..798c6f81 100644 --- a/src/lib/Microsoft.Health.Common/Storage/BlobContainerClientFactory.cs +++ b/src/lib/Microsoft.Health.Common/Storage/BlobContainerClientFactory.cs @@ -13,34 +13,37 @@ namespace Microsoft.Health.Common.Storage { public class BlobContainerClientFactory { - public BlobContainerClient CreateStorageClient(BlobContainerClientOptions options) + public BlobContainerClient CreateStorageClient(BlobContainerClientOptions options, IAzureCredentialProvider provider = null) { EnsureArg.IsNotNull(options); - var containerUri = EnsureArg.IsNotNull(options.BlobStorageContainerUri); + var containerUri = EnsureArg.IsNotNull(options.BlobStorageContainerUri, nameof(options.BlobStorageContainerUri)); var blobUri = new BlobUriBuilder(containerUri); - if (options.ServiceManagedIdentityAuth) + if (options.AuthenticationType == AuthenticationType.ManagedIdentity) { var tokenCredential = new DefaultAzureCredential(); return new BlobContainerClient(containerUri, tokenCredential); } - else if (!string.IsNullOrEmpty(options.ConnectionString)) + else if (options.AuthenticationType == AuthenticationType.ConnectionString) { - return new BlobContainerClient(containerUri.ToString(), blobUri.BlobContainerName); + EnsureArg.IsNotNull(options.ConnectionString, nameof(options.ConnectionString)); + EnsureArg.IsNotNull(blobUri.BlobContainerName); + + return new BlobContainerClient(options.ConnectionString, blobUri.BlobContainerName); + } + else if (options.AuthenticationType == AuthenticationType.Custom) + { + EnsureArg.IsNotNull(provider); + + var tokenCredential = provider.GetCredential(); + return new BlobContainerClient(containerUri, tokenCredential); } else { - throw new Exception($"Unable to create blob container client for {blobUri}"); + var ex = $"Unable to create blob container client for {blobUri}."; + var message = "No authentication type was specified for BlobContainerClientOptions"; + throw new Exception($"{ex} {message}"); } } - - public BlobContainerClient CreateStorageClient(BlobContainerClientOptions options, IAzureCredentialProvider provider) - { - EnsureArg.IsNotNull(options); - var containerUri = EnsureArg.IsNotNull(options.BlobStorageContainerUri); - - var tokenCredential = provider.GetCredential(); - return new BlobContainerClient(containerUri, tokenCredential); - } } } diff --git a/src/lib/Microsoft.Health.Common/Storage/BlobContainerClientOptions.cs b/src/lib/Microsoft.Health.Common/Storage/BlobContainerClientOptions.cs index 07c925c2..992c4136 100644 --- a/src/lib/Microsoft.Health.Common/Storage/BlobContainerClientOptions.cs +++ b/src/lib/Microsoft.Health.Common/Storage/BlobContainerClientOptions.cs @@ -7,14 +7,24 @@ namespace Microsoft.Health.Common.Storage { + public enum AuthenticationType + { + /// A managed identity is used to connect to Storage. + ManagedIdentity, + + /// A connection string is used to connect to Storage. + ConnectionString, + + /// A custom authentication method is used to connect to Storage. + Custom, + } + public class BlobContainerClientOptions { + public AuthenticationType AuthenticationType { get; set; } + public Uri BlobStorageContainerUri { get; set; } public string ConnectionString { get; set; } - - public bool ServiceManagedIdentityAuth { get; set; } - - public bool CustomizedAuth { get; set; } } } diff --git a/src/lib/Microsoft.Health.Events/EventHubProcessor/EventProcessorClientFactoryOptions.cs b/src/lib/Microsoft.Health.Events/Common/EventHubClientOptions.cs similarity index 52% rename from src/lib/Microsoft.Health.Events/EventHubProcessor/EventProcessorClientFactoryOptions.cs rename to src/lib/Microsoft.Health.Events/Common/EventHubClientOptions.cs index ccf739fd..a3752e30 100644 --- a/src/lib/Microsoft.Health.Events/EventHubProcessor/EventProcessorClientFactoryOptions.cs +++ b/src/lib/Microsoft.Health.Events/Common/EventHubClientOptions.cs @@ -3,10 +3,24 @@ // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- -namespace Microsoft.Health.Events.EventHubProcessor +namespace Microsoft.Health.Events.Common { - public class EventProcessorClientFactoryOptions + public enum AuthenticationType { + /// A managed identity is used to connect to the Event Hub. + ManagedIdentity, + + /// A connection string is used to connect to the Event Hub. + ConnectionString, + + /// A custom authentication method is used to connect to the Event Hub. + Custom, + } + + public class EventHubClientOptions + { + public AuthenticationType AuthenticationType { get; set; } + public string EventHubNamespaceFQDN { get; set; } public string EventHubConsumerGroup { get; set; } @@ -14,9 +28,5 @@ public class EventProcessorClientFactoryOptions public string EventHubName { get; set; } public string ConnectionString { get; set; } - - public bool ServiceManagedIdentityAuth { get; set; } - - public bool CustomizedAuth { get; set; } } } diff --git a/src/lib/Microsoft.Health.Events/Common/EventHubFormatter.cs b/src/lib/Microsoft.Health.Events/Common/EventHubFormatter.cs new file mode 100644 index 00000000..5db7b7a5 --- /dev/null +++ b/src/lib/Microsoft.Health.Events/Common/EventHubFormatter.cs @@ -0,0 +1,33 @@ +// ------------------------------------------------------------------------------------------------- +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. +// ------------------------------------------------------------------------------------------------- + +using System; +using EnsureThat; + +namespace Microsoft.Health.Events.Common +{ + public static class EventHubFormatter + { + public static string GetEventHubFQDN(string host) + { + EnsureArg.IsNotEmptyOrWhiteSpace(host); + + if (Uri.IsWellFormedUriString(host, UriKind.Absolute)) + { + var uri = new Uri(host); + host = uri.Host; + } + + if (Uri.CheckHostName(host) != UriHostNameType.Unknown) + { + return host; + } + else + { + throw new Exception($"The event hub FQDN: {host} is not valid"); + } + } + } +} diff --git a/src/lib/Microsoft.Health.Events/EventHubProcessor/EventProcessorClientFactory.cs b/src/lib/Microsoft.Health.Events/EventHubProcessor/EventProcessorClientFactory.cs index 7529511e..48657fbb 100644 --- a/src/lib/Microsoft.Health.Events/EventHubProcessor/EventProcessorClientFactory.cs +++ b/src/lib/Microsoft.Health.Events/EventHubProcessor/EventProcessorClientFactory.cs @@ -9,41 +9,48 @@ using Azure.Storage.Blobs; using EnsureThat; using Microsoft.Health.Common.Auth; +using Microsoft.Health.Events.Common; namespace Microsoft.Health.Events.EventHubProcessor { public class EventProcessorClientFactory : IEventProcessorClientFactory { - public EventProcessorClient CreateProcessorClient(BlobContainerClient blobContainerClient, EventProcessorClientFactoryOptions options, EventProcessorClientOptions eventProcessorClientOptions) + public EventProcessorClient CreateProcessorClient(BlobContainerClient blobContainerClient, EventHubClientOptions options, EventProcessorClientOptions eventProcessorClientOptions, IAzureCredentialProvider provider = null) { EnsureArg.IsNotNull(blobContainerClient); - EnsureArg.IsNotNull(options); EnsureArg.IsNotNull(eventProcessorClientOptions); + EnsureArg.IsNotNull(options); + EnsureArg.IsNotNull(options.EventHubConsumerGroup, nameof(options.EventHubConsumerGroup)); - if (options.ServiceManagedIdentityAuth) + if (options.AuthenticationType == AuthenticationType.ManagedIdentity) { + EnsureArg.IsNotNull(options.EventHubNamespaceFQDN); + EnsureArg.IsNotNull(options.EventHubName); + var tokenCredential = new DefaultAzureCredential(); - return new EventProcessorClient(blobContainerClient, options.EventHubConsumerGroup, options.EventHubNamespaceFQDN, options.EventHubName, tokenCredential, eventProcessorClientOptions); + var eventHubFQDN = EventHubFormatter.GetEventHubFQDN(options.EventHubNamespaceFQDN); + return new EventProcessorClient(blobContainerClient, options.EventHubConsumerGroup, eventHubFQDN, options.EventHubName, tokenCredential, eventProcessorClientOptions); } - else if (!string.IsNullOrEmpty(options.ConnectionString)) + else if (options.AuthenticationType == AuthenticationType.ConnectionString) { - return new EventProcessorClient(blobContainerClient, options.EventHubConsumerGroup, options.ConnectionString, options.EventHubName, eventProcessorClientOptions); + EnsureArg.IsNotNull(options.ConnectionString); + return new EventProcessorClient(blobContainerClient, options.EventHubConsumerGroup, options.ConnectionString, eventProcessorClientOptions); + } + else if (options.AuthenticationType == AuthenticationType.Custom) + { + EnsureArg.IsNotNull(options.EventHubNamespaceFQDN); + EnsureArg.IsNotNull(options.EventHubName); + EnsureArg.IsNotNull(provider); + + var eventHubFQDN = EventHubFormatter.GetEventHubFQDN(options.EventHubNamespaceFQDN); + return new EventProcessorClient(blobContainerClient, options.EventHubConsumerGroup, eventHubFQDN, options.EventHubName, provider.GetCredential(), eventProcessorClientOptions); } else { - throw new Exception($"Unable to create Event Hub processor client for {options.EventHubName}"); + var ex = $"Unable to create Event Hub processor client for {options.EventHubName}."; + var message = "No authentication type was specified for EventHubClientOptions"; + throw new Exception($"{ex} {message}"); } } - - public EventProcessorClient CreateProcessorClient(IAzureCredentialProvider provider, BlobContainerClient blobContainerClient, EventProcessorClientFactoryOptions options, EventProcessorClientOptions eventProcessorClientOptions) - { - EnsureArg.IsNotNull(provider); - EnsureArg.IsNotNull(blobContainerClient); - EnsureArg.IsNotNull(options); - EnsureArg.IsNotNull(eventProcessorClientOptions); - - var tokenCredential = provider.GetCredential(); - return new EventProcessorClient(blobContainerClient, options.EventHubConsumerGroup, options.EventHubNamespaceFQDN, options.EventHubName, tokenCredential, eventProcessorClientOptions); - } } } diff --git a/src/lib/Microsoft.Health.Events/EventHubProcessor/IEventProcessorClientFactory.cs b/src/lib/Microsoft.Health.Events/EventHubProcessor/IEventProcessorClientFactory.cs index b299de3b..9d459d42 100644 --- a/src/lib/Microsoft.Health.Events/EventHubProcessor/IEventProcessorClientFactory.cs +++ b/src/lib/Microsoft.Health.Events/EventHubProcessor/IEventProcessorClientFactory.cs @@ -6,13 +6,12 @@ using Azure.Messaging.EventHubs; using Azure.Storage.Blobs; using Microsoft.Health.Common.Auth; +using Microsoft.Health.Events.Common; namespace Microsoft.Health.Events.EventHubProcessor { public interface IEventProcessorClientFactory { - EventProcessorClient CreateProcessorClient(BlobContainerClient blobContainerClient, EventProcessorClientFactoryOptions options, EventProcessorClientOptions eventProcessorClientOptions); - - EventProcessorClient CreateProcessorClient(IAzureCredentialProvider provider, BlobContainerClient blobContainerClient, EventProcessorClientFactoryOptions options, EventProcessorClientOptions eventProcessorClientOptions); + EventProcessorClient CreateProcessorClient(BlobContainerClient blobContainerClient, EventHubClientOptions options, EventProcessorClientOptions eventProcessorClientOptions, IAzureCredentialProvider provider = null); } } diff --git a/src/lib/Microsoft.Health.Events/EventProducers/EventProducerClientFactory.cs b/src/lib/Microsoft.Health.Events/EventProducers/EventProducerClientFactory.cs index c7902357..9d7b3368 100644 --- a/src/lib/Microsoft.Health.Events/EventProducers/EventProducerClientFactory.cs +++ b/src/lib/Microsoft.Health.Events/EventProducers/EventProducerClientFactory.cs @@ -7,26 +7,46 @@ using Azure.Identity; using Azure.Messaging.EventHubs.Producer; using EnsureThat; +using Microsoft.Health.Common.Auth; +using Microsoft.Health.Events.Common; namespace Microsoft.Health.Events.EventProducers { public class EventProducerClientFactory : IEventProducerClientFactory { - public EventHubProducerClient GetEventHubProducerClient(EventProducerClientOptions options) + public EventHubProducerClient GetEventHubProducerClient(EventHubClientOptions options, IAzureCredentialProvider provider = null) { EnsureArg.IsNotNull(options); - if (options.ServiceManagedIdentityAuth) + + if (options.AuthenticationType == AuthenticationType.ManagedIdentity) { + EnsureArg.IsNotNull(options.EventHubName); + EnsureArg.IsNotNull(options.EventHubNamespaceFQDN); + var tokenCredential = new DefaultAzureCredential(); - return new EventHubProducerClient(options.EventHubNamespaceFQDN, options.EventHubName, tokenCredential); + var eventHubFQDN = EventHubFormatter.GetEventHubFQDN(options.EventHubNamespaceFQDN); + return new EventHubProducerClient(eventHubFQDN, options.EventHubName, tokenCredential); + } + else if (options.AuthenticationType == AuthenticationType.ConnectionString) + { + EnsureArg.IsNotNull(options.ConnectionString); + + return new EventHubProducerClient(options.ConnectionString); } - else if (!string.IsNullOrEmpty(options.ConnectionString)) + else if (options.AuthenticationType == AuthenticationType.Custom) { - return new EventHubProducerClient(options.ConnectionString, options.EventHubName); + EnsureArg.IsNotNull(options.EventHubName); + EnsureArg.IsNotNull(options.EventHubNamespaceFQDN); + EnsureArg.IsNotNull(provider); + + var eventHubFQDN = EventHubFormatter.GetEventHubFQDN(options.EventHubNamespaceFQDN); + return new EventHubProducerClient(eventHubFQDN, options.EventHubName, provider.GetCredential()); } else { - throw new Exception($"Unable to create Event Hub processor client for {options.EventHubName}"); + var ex = $"Unable to create Event Hub producer client for {options.EventHubName}"; + var message = "No authentication type was specified for EventHubClientOptions."; + throw new Exception($"{ex} {message}"); } } } diff --git a/src/lib/Microsoft.Health.Events/EventProducers/EventProducerClientOptions.cs b/src/lib/Microsoft.Health.Events/EventProducers/EventProducerClientOptions.cs deleted file mode 100644 index 3fc4d282..00000000 --- a/src/lib/Microsoft.Health.Events/EventProducers/EventProducerClientOptions.cs +++ /dev/null @@ -1,22 +0,0 @@ -// ------------------------------------------------------------------------------------------------- -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. -// ------------------------------------------------------------------------------------------------- - -namespace Microsoft.Health.Events.EventProducers -{ - public class EventProducerClientOptions - { - public string EventHubNamespaceFQDN { get; set; } - - public string EventHubConsumerGroup { get; set; } - - public string EventHubName { get; set; } - - public string ConnectionString { get; set; } - - public bool ServiceManagedIdentityAuth { get; set; } - - public bool CustomizedAuth { get; set; } - } -} diff --git a/src/lib/Microsoft.Health.Events/EventProducers/IEventProducerClientFactory.cs b/src/lib/Microsoft.Health.Events/EventProducers/IEventProducerClientFactory.cs index f10c008f..3eb6d703 100644 --- a/src/lib/Microsoft.Health.Events/EventProducers/IEventProducerClientFactory.cs +++ b/src/lib/Microsoft.Health.Events/EventProducers/IEventProducerClientFactory.cs @@ -4,11 +4,13 @@ // ------------------------------------------------------------------------------------------------- using Azure.Messaging.EventHubs.Producer; +using Microsoft.Health.Common.Auth; +using Microsoft.Health.Events.Common; namespace Microsoft.Health.Events.EventProducers { public interface IEventProducerClientFactory { - EventHubProducerClient GetEventHubProducerClient(EventProducerClientOptions options); + EventHubProducerClient GetEventHubProducerClient(EventHubClientOptions options, IAzureCredentialProvider provider = null); } }