예제 #1
0
            public void Connect(string connectionString, string eventHubName, string serviceUri, string tenantIdentity, string resourceIdentity, string clientIdentity)
            {
                EventHubName = eventHubName;

                if (!string.IsNullOrEmpty(serviceUri))
                {
                    var tokenCredentials = new AzureServiceTokenProviderCredentials(tenantIdentity, resourceIdentity, clientIdentity);
                    _client = new Azure.Messaging.EventHubs.Producer.EventHubProducerClient(serviceUri, eventHubName, tokenCredentials);
                }
                else if (string.IsNullOrEmpty(eventHubName))
                {
                    _client = new Azure.Messaging.EventHubs.Producer.EventHubProducerClient(connectionString);
                }
                else
                {
                    _client = new Azure.Messaging.EventHubs.Producer.EventHubProducerClient(connectionString, eventHubName);
                }
            }