diff --git a/src/NLog.Extensions.AzureBlobStorage/BlobStorageTarget.cs b/src/NLog.Extensions.AzureBlobStorage/BlobStorageTarget.cs index 8b71190..da79e9d 100644 --- a/src/NLog.Extensions.AzureBlobStorage/BlobStorageTarget.cs +++ b/src/NLog.Extensions.AzureBlobStorage/BlobStorageTarget.cs @@ -348,7 +348,7 @@ protected override Task WriteAsyncTask(IList logEvents, Cancellati } } - return Task.WhenAll(multipleTasks ?? new Task[0]); + return multipleTasks?.Count > 0 ? Task.WhenAll(multipleTasks) : Task.CompletedTask; } private byte[] CreateBlobPayload(IList logEvents) @@ -474,7 +474,7 @@ public override int GetHashCode() } } - class CloudBlobService : ICloudBlobService + private sealed class CloudBlobService : ICloudBlobService { private IDictionary _blobMetadata; private IDictionary _blobTags; diff --git a/src/NLog.Extensions.AzureBlobStorage/NLog.Extensions.AzureBlobStorage.csproj b/src/NLog.Extensions.AzureBlobStorage/NLog.Extensions.AzureBlobStorage.csproj index 48f243c..795a23d 100644 --- a/src/NLog.Extensions.AzureBlobStorage/NLog.Extensions.AzureBlobStorage.csproj +++ b/src/NLog.Extensions.AzureBlobStorage/NLog.Extensions.AzureBlobStorage.csproj @@ -24,9 +24,7 @@ https://github.com/JDetmar/NLog.Extensions.AzureStorage.git MIT -- Updated Azure.Identity ver. 1.14.2 to fix security issue -- Updated NLog ver. 5.2.5 to support build-triming -- Updated Azure.Storage.Blobs ver. 12.24.1 +- Added support for Proxy-options: ProxyAddress, ProxyLogin, ProxyPassword, NoProxy, UseDefaultCredentialsForProxy Docs: https://github.com/JDetmar/NLog.Extensions.AzureStorage/blob/master/src/NLog.Extensions.AzureBlobStorage/README.md diff --git a/src/NLog.Extensions.AzureBlobStorage/README.md b/src/NLog.Extensions.AzureBlobStorage/README.md index 7d0337e..0751eea 100644 --- a/src/NLog.Extensions.AzureBlobStorage/README.md +++ b/src/NLog.Extensions.AzureBlobStorage/README.md @@ -25,7 +25,7 @@ ``` -### Parameters +### General Options _name_ - Name of the target. @@ -37,9 +37,11 @@ _container_ - Azure blob container name. [Layout](https://github.com/NLog/NLog/w _contentType_ - Azure blob ContentType (Default = text/plain) -_connectionString_ - Azure storage connection string. Ex. `UseDevelopmentStorage=true;` +_connectionString_ - Azure Blob Storage connection string from your storage account. Required unless using `ServiceUri`. -_serviceUri_ - Uri to reference the blob service (e.g. https://{account_name}.blob.core.windows.net). Input for `BlobServiceClient`. Required, when `connectionString` is not configured. Overrides `connectionString` when both are set. +_serviceUri_ - Uri to reference the blob service (e.g. https://{account_name}.blob.core.windows.net). Alternative to ConnectionString, where Managed Identiy is applied from DefaultAzureCredential. + +### Authentication Options _managedIdentityClientId_ - Sets `ManagedIdentityClientId` on `DefaultAzureCredentialOptions`. Requires `serviceUri`. @@ -57,6 +59,8 @@ _clientAuthId_ - clientId for `ClientSecretCredential` authentication. Requires _clientAuthSecret_ - clientSecret for `ClientSecretCredential` authentication. Requires `serviceUri`,`tenantIdentity` and `clientAuthId`. +### Proxy Options + _noProxy_ - Bypasses any system proxy and proxy in `ProxyAddress` when set to `true`. _proxyAddress_ - Address of the proxy server to use (e.g. http://proxyserver:8080). @@ -65,7 +69,7 @@ _proxyLogin_ - Login to use for the proxy server. Requires `proxyPassword`. _proxyPassword_ - Password to use for the proxy server. Requires `proxyLogin`. -_useDefaultCredentialsForProxy_ - Uses the default credentials (`System.Net.CredentialCache.DefaultCredentials`) for the proxy server, overriding any values that may have been set in `proxyLogin` and `proxyPassword`. +_useDefaultCredentialsForProxy_ - Uses the default credentials (`System.Net.CredentialCache.DefaultCredentials`) for the proxy server. ### Batching Policy diff --git a/src/NLog.Extensions.AzureDataTables/DataTablesTarget.cs b/src/NLog.Extensions.AzureDataTables/DataTablesTarget.cs index 7589b89..0ca1dee 100644 --- a/src/NLog.Extensions.AzureDataTables/DataTablesTarget.cs +++ b/src/NLog.Extensions.AzureDataTables/DataTablesTarget.cs @@ -356,7 +356,7 @@ protected override Task WriteAsyncTask(IList logEvents, Cancellati } } - return Task.WhenAll(multipleTasks ?? new Task[0]); + return multipleTasks?.Count > 0 ? Task.WhenAll(multipleTasks) : Task.CompletedTask; } private async Task WriteMultipleBatchesAsync(IEnumerable> batchCollection, string tableName, CancellationToken cancellationToken) @@ -485,7 +485,7 @@ private static string TryLookupValue(Func lookupFunc, string lookupType) } } - class CloudTableService : ICloudTableService + private sealed class CloudTableService : ICloudTableService { private TableServiceClient _client; private TableClient _table; diff --git a/src/NLog.Extensions.AzureDataTables/NLog.Extensions.AzureDataTables.csproj b/src/NLog.Extensions.AzureDataTables/NLog.Extensions.AzureDataTables.csproj index d84fa7b..3bc9ce7 100644 --- a/src/NLog.Extensions.AzureDataTables/NLog.Extensions.AzureDataTables.csproj +++ b/src/NLog.Extensions.AzureDataTables/NLog.Extensions.AzureDataTables.csproj @@ -24,9 +24,8 @@ https://github.com/JDetmar/NLog.Extensions.AzureStorage.git MIT -- Updated Azure.Identity ver. 1.14.2 to fix security issue -- Updated NLog ver. 5.2.5 to support build-triming -- Updated Azure.Data.Tables ver. 12.11.0 +- Added support for Proxy-options: ProxyAddress, ProxyLogin, ProxyPassword, NoProxy, UseDefaultCredentialsForProxy +- Added support for Authentication-options: ClientAuthId + ClientAuthSecret Docs: https://github.com/JDetmar/NLog.Extensions.AzureStorage/blob/master/src/NLog.Extensions.AzureDataTables/README.md diff --git a/src/NLog.Extensions.AzureDataTables/README.md b/src/NLog.Extensions.AzureDataTables/README.md index 93be51a..111c47b 100644 --- a/src/NLog.Extensions.AzureDataTables/README.md +++ b/src/NLog.Extensions.AzureDataTables/README.md @@ -22,16 +22,26 @@ Supports both Azure Storage Tables and CosmosDB Tables. logTimeStampFormat="O" /> ``` -### Parameters +### General Options _name_ - Name of the target. _layout_ - Text to be rendered. [Layout](https://github.com/NLog/NLog/wiki/Layouts) Required. -_connectionString_ - Azure storage connection string. [Layout](https://github.com/NLog/NLog/wiki/Layouts) +_connectionString_ - Azure storage connection string. [Layout](https://github.com/NLog/NLog/wiki/Layouts). Required unless using `serviceUri`. _serviceUri_ - Alternative to ConnectionString, where Managed Identiy is acquired from DefaultAzureCredential. +_tableName_ - Azure table name. [Layout](https://github.com/NLog/NLog/wiki/Layouts) + +_rowKey_ - Azure Table RowKey. [Layout](https://github.com/NLog/NLog/wiki/Layouts). Default = "InverseTicks_${guid}" + +_partitionKey_ - Azure PartitionKey. [Layout](https://github.com/NLog/NLog/wiki/Layouts). Default = `${logger}` + +_logTimeStampFormat_ - Default Log TimeStamp is set to 'O' for [Round-trip](https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings#the-round-trip-o-o-format-specifier) format if not specified. + +## Authentication Options + _managedIdentityClientId_ - Sets `ManagedIdentityClientId` on `DefaultAzureCredentialOptions`. Requires `serviceUri` _managedIdentityResourceId_ - resourceId for `ManagedIdentityResourceId` on `DefaultAzureCredentialOptions`, do not use together with `ManagedIdentityClientId`. Requires `serviceUri`. @@ -48,6 +58,8 @@ _clientAuthId_ - clientId for `ClientSecretCredential` authentication. Requires _clientAuthSecret_ - clientSecret for `ClientSecretCredential` authentication. Requires `serviceUri`,`tenantIdentity` and `clientAuthId`. +## Proxy Options + _noProxy_ - Bypasses any system proxy and proxy in `ProxyAddress` when set to `true`. _proxyAddress_ - Address of the proxy server to use (e.g. http://proxyserver:8080). @@ -56,15 +68,7 @@ _proxyLogin_ - Login to use for the proxy server. Requires `proxyPassword`. _proxyPassword_ - Password to use for the proxy server. Requires `proxyLogin`. -_useDefaultCredentialsForProxy_ - Uses the default credentials (`System.Net.CredentialCache.DefaultCredentials`) for the proxy server, overriding any values that may have been set in `proxyLogin` and `proxyPassword`. - -_tableName_ - Azure table name. [Layout](https://github.com/NLog/NLog/wiki/Layouts) - -_rowKey_ - Azure Table RowKey. [Layout](https://github.com/NLog/NLog/wiki/Layouts). Default = "InverseTicks_${guid}" - -_partitionKey_ - Azure PartitionKey. [Layout](https://github.com/NLog/NLog/wiki/Layouts). Default = `${logger}` - -_logTimeStampFormat_ - Default Log TimeStamp is set to 'O' for [Round-trip](https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings#the-round-trip-o-o-format-specifier) format if not specified. +_useDefaultCredentialsForProxy_ - Uses the default credentials (`System.Net.CredentialCache.DefaultCredentials`) for the proxy server. ### Dynamic TableEntity Instead of using the predefined NLogEntity-properties, then one can specify wanted properties: diff --git a/src/NLog.Extensions.AzureEventGrid/NLog.Extensions.AzureEventGrid.csproj b/src/NLog.Extensions.AzureEventGrid/NLog.Extensions.AzureEventGrid.csproj index 99f2b33..66ea708 100644 --- a/src/NLog.Extensions.AzureEventGrid/NLog.Extensions.AzureEventGrid.csproj +++ b/src/NLog.Extensions.AzureEventGrid/NLog.Extensions.AzureEventGrid.csproj @@ -24,9 +24,8 @@ https://github.com/JDetmar/NLog.Extensions.AzureStorage.git MIT -- Updated Azure.Identity ver. 1.14.2 to fix security issue -- Updated NLog ver. 5.2.5 to support build-triming -- Updated Azure.Messaging.EventGrid ver. 5.0.0 +- Added support for Proxy-options: ProxyAddress, ProxyLogin, ProxyPassword, NoProxy, UseDefaultCredentialsForProxy +- Added support for Authentication-options: ClientAuthId + ClientAuthSecret Docs: https://github.com/JDetmar/NLog.Extensions.AzureStorage/blob/master/src/NLog.Extensions.AzureEventGrid/README.md diff --git a/src/NLog.Extensions.AzureEventGrid/README.md b/src/NLog.Extensions.AzureEventGrid/README.md index c098ec9..bd5633e 100644 --- a/src/NLog.Extensions.AzureEventGrid/README.md +++ b/src/NLog.Extensions.AzureEventGrid/README.md @@ -28,7 +28,7 @@ ``` -### Parameters +### General Options _name_ - Name of the target. @@ -48,6 +48,8 @@ _dataFormat_ - Format of the data-payload (Binary / Json). Default Binary. `Stri _dataSchema_ - Schema version of the data-payload. [Layout](https://github.com/NLog/NLog/wiki/Layouts) +### Authentication Options + _managedIdentityClientId_ - Sets `ManagedIdentityClientId` on `DefaultAzureCredentialOptions`. Requires `serviceUri`. _managedIdentityResourceId_ - resourceId for `ManagedIdentityResourceId` on `DefaultAzureCredentialOptions`, do not use together with `ManagedIdentityClientId`. Requires `serviceUri`. @@ -62,6 +64,8 @@ _clientAuthId_ - clientId for `ClientSecretCredential` authentication. Requires _clientAuthSecret_ - clientSecret for `ClientSecretCredential` authentication. Requires `tenantIdentity` and `clientAuthId`. +### Proxy Options + _noProxy_ - Bypasses any system proxy and proxy in `ProxyAddress` when set to `true`. _proxyAddress_ - Address of the proxy server to use (e.g. http://proxyserver:8080). @@ -70,8 +74,7 @@ _proxyLogin_ - Login to use for the proxy server. Requires `proxyPassword`. _proxyPassword_ - Password to use for the proxy server. Requires `proxyLogin`. -_useDefaultCredentialsForProxy_ - Uses the default credentials (`System.Net.CredentialCache.DefaultCredentials`) for the proxy server, overriding any values that may have been set in `proxyLogin` and `proxyPassword`. -Only applies if `noProxy` is not set to `true`. +_useDefaultCredentialsForProxy_ - Uses the default credentials (`System.Net.CredentialCache.DefaultCredentials`) for the proxy server. ### Retry Policy diff --git a/src/NLog.Extensions.AzureEventHub/EventHubTarget.cs b/src/NLog.Extensions.AzureEventHub/EventHubTarget.cs index 8f0cd1c..70837ab 100644 --- a/src/NLog.Extensions.AzureEventHub/EventHubTarget.cs +++ b/src/NLog.Extensions.AzureEventHub/EventHubTarget.cs @@ -7,6 +7,7 @@ using Azure.Messaging.EventHubs; using NLog.Common; using NLog.Config; +using NLog.Extensions.AzureBlobStorage; using NLog.Extensions.AzureStorage; using NLog.Layouts; @@ -161,13 +162,50 @@ public class EventHubTarget : AsyncTaskTarget /// /// The proxy to use for communication over web sockets. /// - public Layout WebSocketProxyAddress { get; set; } + [Obsolete("Replaced by ProxyAddress to align with other NLog Targets for Azure")] + public Layout WebSocketProxyAddress { get => ProxyAddress; set => ProxyAddress = value; } /// /// Custom endpoint address that can be used when establishing the connection. /// public Layout CustomEndpointAddress { get; set; } + /// + /// A unique name used to identify the producer. If null or empty, a GUID will be used as the identifier. + /// + public Layout EventProducerIdentifier { get; set; } + + /// + /// Bypasses any system proxy and proxy in when set to . + /// Overrides . + /// + /// Only applies when = + public bool NoProxy { get; set; } + + /// + /// Address of the proxy server to use (e.g. http://proxyserver:8080). + /// + /// Only applies when = + public Layout ProxyAddress { get; set; } + + /// + /// Login to use for the proxy server. Requires . + /// + /// Only applies when = + public Layout ProxyLogin { get; set; } + + /// + /// Password to use for the proxy server. Requires . + /// + /// Only applies when = + public Layout ProxyPassword { get; set; } + + /// + /// Uses the default credentials () for the proxy server, overriding any values that may have been set in and . + /// + /// Only applies when = + public bool UseDefaultCredentialsForProxy { get; set; } + /// /// Gets a list of user properties (aka custom properties) to add to the AMQP message /// @@ -225,6 +263,7 @@ protected override void InitializeTarget() string useWebSockets = string.Empty; string webSocketProxyAddress = string.Empty; string customEndPointAddress = string.Empty; + string eventProducerIdentifier = string.Empty; var defaultLogEvent = LogEventInfo.CreateNullEvent(); @@ -245,15 +284,26 @@ protected override void InitializeTarget() clientAuthSecret = ClientAuthSecret?.Render(defaultLogEvent); } + eventProducerIdentifier = EventProducerIdentifier?.Render(defaultLogEvent) ?? string.Empty; + useWebSockets = UseWebSockets?.Render(defaultLogEvent) ?? string.Empty; if (!string.IsNullOrEmpty(useWebSockets) && (string.Equals(useWebSockets.Trim(), bool.TrueString, StringComparison.OrdinalIgnoreCase) || string.Equals(useWebSockets.Trim(), "1", StringComparison.OrdinalIgnoreCase))) { useWebSockets = bool.TrueString; } customEndPointAddress = CustomEndpointAddress?.Render(defaultLogEvent) ?? string.Empty; - webSocketProxyAddress = WebSocketProxyAddress?.Render(defaultLogEvent) ?? string.Empty; - _eventHubService.Connect(connectionString, eventHubName, serviceUri, tenantIdentity, managedIdentityResourceId, managedIdentityClientId, sharedAccessSignature, storageAccountName, storageAccountAccessKey, clientAuthId, clientAuthSecret, bool.TrueString == useWebSockets, webSocketProxyAddress, customEndPointAddress); + var proxySettings = new ProxySettings + { + NoProxy = NoProxy, + UseDefaultCredentials = UseDefaultCredentialsForProxy, + Address = ProxyAddress?.Render(defaultLogEvent), + Login = ProxyLogin?.Render(defaultLogEvent), + Password = ProxyPassword?.Render(defaultLogEvent) + }; + proxySettings = proxySettings.RequiresManualProxyConfiguration ? proxySettings : null; + + _eventHubService.Connect(connectionString, eventHubName, serviceUri, tenantIdentity, managedIdentityResourceId, managedIdentityClientId, sharedAccessSignature, storageAccountName, storageAccountAccessKey, clientAuthId, clientAuthSecret, eventProducerIdentifier, bool.TrueString == useWebSockets, customEndPointAddress, proxySettings); InternalLogger.Debug("AzureEventHubTarget(Name={0}): Initialized", Name); } catch (Exception ex) @@ -556,17 +606,21 @@ private sealed class EventHubService : IEventHubService public string EventHubName { get; private set; } - public void Connect(string connectionString, string eventHubName, string serviceUri, string tenantIdentity, string managedIdentityResourceId, string managedIdentityClientId, string sharedAccessSignature, string storageAccountName, string storageAccountAccessKey, string clientAuthId, string clientAuthSecret, bool useWebSockets, string webSocketsProxyAddress, string endPointAddress) + public void Connect(string connectionString, string eventHubName, string serviceUri, string tenantIdentity, string managedIdentityResourceId, string managedIdentityClientId, string sharedAccessSignature, string storageAccountName, string storageAccountAccessKey, string clientAuthId, string clientAuthSecret, string eventProducerIdentifier, bool useWebSockets, string endPointAddress, ProxySettings proxySettings) { EventHubName = eventHubName; Azure.Messaging.EventHubs.Producer.EventHubProducerClientOptions options = default; - if (useWebSockets || !string.IsNullOrEmpty(webSocketsProxyAddress) || !string.IsNullOrEmpty(endPointAddress)) + if (useWebSockets || !string.IsNullOrEmpty(endPointAddress) || !string.IsNullOrEmpty(eventProducerIdentifier)) { options = new Azure.Messaging.EventHubs.Producer.EventHubProducerClientOptions(); options.ConnectionOptions.TransportType = useWebSockets ? EventHubsTransportType.AmqpWebSockets : options.ConnectionOptions.TransportType; - options.ConnectionOptions.Proxy = !string.IsNullOrEmpty(webSocketsProxyAddress) ? new System.Net.WebProxy(webSocketsProxyAddress, true) : options.ConnectionOptions.Proxy; - options.ConnectionOptions.CustomEndpointAddress = !string.IsNullOrEmpty(endPointAddress) ? new Uri(endPointAddress) : options.ConnectionOptions.CustomEndpointAddress; + if (useWebSockets && proxySettings != null) + options.ConnectionOptions.Proxy = proxySettings.CreateWebProxy(options.ConnectionOptions.Proxy); + if (!string.IsNullOrEmpty(endPointAddress)) + options.ConnectionOptions.CustomEndpointAddress = new Uri(endPointAddress); + if (!string.IsNullOrEmpty(eventProducerIdentifier)) + options.Identifier = eventProducerIdentifier; } if (string.IsNullOrWhiteSpace(serviceUri)) diff --git a/src/NLog.Extensions.AzureEventHub/IEventHubService.cs b/src/NLog.Extensions.AzureEventHub/IEventHubService.cs index ce2a4dd..3764ce2 100644 --- a/src/NLog.Extensions.AzureEventHub/IEventHubService.cs +++ b/src/NLog.Extensions.AzureEventHub/IEventHubService.cs @@ -2,13 +2,14 @@ using System.Threading; using System.Threading.Tasks; using Azure.Messaging.EventHubs; +using NLog.Extensions.AzureBlobStorage; namespace NLog.Extensions.AzureStorage { internal interface IEventHubService { string EventHubName { get; } - void Connect(string connectionString, string eventHubName, string serviceUri, string tenantIdentity, string managedIdentityResourceId, string managedIdentityClientId, string sharedAccessSignature, string storageAccountName, string storageAccountAccessKey, string clientAuthId, string clientAuthSecret, bool useWebSockets, string webSocketsProxyAddress, string endPointAddress); + void Connect(string connectionString, string eventHubName, string serviceUri, string tenantIdentity, string managedIdentityResourceId, string managedIdentityClientId, string sharedAccessSignature, string storageAccountName, string storageAccountAccessKey, string clientAuthId, string clientAuthSecret, string eventProducerIdentifier, bool useWebSockets, string endPointAddress, ProxySettings proxySettings); Task CloseAsync(); Task SendAsync(IEnumerable eventDataBatch, string partitionKey, CancellationToken cancellationToken); } diff --git a/src/NLog.Extensions.AzureEventHub/NLog.Extensions.AzureEventHub.csproj b/src/NLog.Extensions.AzureEventHub/NLog.Extensions.AzureEventHub.csproj index d56ffac..c9fc58f 100644 --- a/src/NLog.Extensions.AzureEventHub/NLog.Extensions.AzureEventHub.csproj +++ b/src/NLog.Extensions.AzureEventHub/NLog.Extensions.AzureEventHub.csproj @@ -24,9 +24,9 @@ https://github.com/JDetmar/NLog.Extensions.AzureStorage.git MIT -- Updated Azure.Identity ver. 1.14.2 to fix security issue -- Updated NLog ver. 5.2.5 to support build-triming -- Updated Azure.Messaging.EventHubs ver. 5.12.2 +- Added support for Proxy-options: ProxyAddress, ProxyLogin, ProxyPassword, NoProxy, UseDefaultCredentialsForProxy +- Added support for Authentication-options: ClientAuthId + ClientAuthSecret +- Added support for EventProducerIdentifier-option Docs: https://github.com/JDetmar/NLog.Extensions.AzureStorage/blob/master/src/NLog.Extensions.AzureEventHub/README.md @@ -39,6 +39,7 @@ Docs: https://github.com/JDetmar/NLog.Extensions.AzureStorage/blob/master/src/NL + diff --git a/src/NLog.Extensions.AzureEventHub/README.md b/src/NLog.Extensions.AzureEventHub/README.md index 8d13ed8..8455bda 100644 --- a/src/NLog.Extensions.AzureEventHub/README.md +++ b/src/NLog.Extensions.AzureEventHub/README.md @@ -34,7 +34,7 @@ ``` -### Parameters +### General Options _name_ - Name of the target. @@ -54,12 +54,14 @@ _correlationId_ - EventData Correlationid. [Layout](https://github.com/NLog/NLog _useWebSockets_ - Enable AmqpWebSockets. Ex. true/false (optional) -_webSocketProxyAddress_ - Custom WebProxy address for WebSockets (optional) - _customEndpointAddress_ - Custom endpoint address that can be used when establishing the connection (optional) _serviceUri_ - Alternative to ConnectionString, where Managed Identiy is applied from DefaultAzureCredential. +_eventProducerIdentifier_ - A unique name used to identify the event producer. If null or empty, a GUID will be used as the identifier (optional) + +### Authentication Options + _managedIdentityClientId_ - Sets `ManagedIdentityClientId` on `DefaultAzureCredentialOptions`. Requires `serviceUri` _managedIdentityResourceId_ - resourceId for `ManagedIdentityResourceId` on `DefaultAzureCredentialOptions`, do not use together with `ManagedIdentityClientId`. Requires `serviceUri`. @@ -76,6 +78,18 @@ _clientAuthId_ - clientId for `ClientSecretCredential` authentication. Requires _clientAuthSecret_ - clientSecret for `ClientSecretCredential` authentication. Requires `serviceUri`,`tenantIdentity` and `clientAuthId`. +### Proxy Options + +_noProxy_ - Bypasses any system proxy and proxy in `ProxyAddress` when set to `true`. Requires `useWebSockets = true`. + +_proxyAddress_ - Address of the proxy server to use (e.g. http://proxyserver:8080). Requires `useWebSockets = true`. + +_proxyLogin_ - Login to use for the proxy server. Requires `proxyPassword`. Requires `useWebSockets = true`. + +_proxyPassword_ - Password to use for the proxy server. Requires `proxyLogin`. Requires `useWebSockets = true`. + +_useDefaultCredentialsForProxy_ - Uses the default credentials (`System.Net.CredentialCache.DefaultCredentials`) for the proxy server. Requires `useWebSockets = true`. + ### Batching Policy _maxBatchSizeBytes_ - Max size of a single batch in bytes [Integer](https://github.com/NLog/NLog/wiki/Data-types) (Default=1024*1024) diff --git a/src/NLog.Extensions.AzureQueueStorage/NLog.Extensions.AzureQueueStorage.csproj b/src/NLog.Extensions.AzureQueueStorage/NLog.Extensions.AzureQueueStorage.csproj index e57d63f..01c4e42 100644 --- a/src/NLog.Extensions.AzureQueueStorage/NLog.Extensions.AzureQueueStorage.csproj +++ b/src/NLog.Extensions.AzureQueueStorage/NLog.Extensions.AzureQueueStorage.csproj @@ -23,9 +23,8 @@ https://github.com/JDetmar/NLog.Extensions.AzureStorage.git MIT -- Updated Azure.Identity ver. 1.14.2 to fix security issue -- Updated NLog ver. 5.2.5 to support build-triming -- Updated Azure.Storage.Queues ver. 12.22.0 +- Added support for Proxy-options: ProxyAddress, ProxyLogin, ProxyPassword, NoProxy, UseDefaultCredentialsForProxy +- Added support for Authentication-options: ClientAuthId + ClientAuthSecret Docs: https://github.com/JDetmar/NLog.Extensions.AzureStorage/blob/master/src/NLog.Extensions.AzureQueueStorage/README.md diff --git a/src/NLog.Extensions.AzureQueueStorage/README.md b/src/NLog.Extensions.AzureQueueStorage/README.md index 93ff160..0680720 100644 --- a/src/NLog.Extensions.AzureQueueStorage/README.md +++ b/src/NLog.Extensions.AzureQueueStorage/README.md @@ -23,7 +23,7 @@ ``` -### Parameters +### General Options _name_ - Name of the target. @@ -31,10 +31,16 @@ _layout_ - Queue Message Text to be rendered. [Layout](https://github.com/NLog/N _queueName_ - QueueName. [Layout](https://github.com/NLog/NLog/wiki/Layouts) -_connectionString_ - Azure storage connection string. Ex. `UseDevelopmentStorage=true;` +_connectionString_ - Azure Queue Storage connection string from your storage account. Required unless using `serviceUri`. _serviceUri_ - Alternative to ConnectionString, where Managed Identiy is acquired from DefaultAzureCredential. +_timeToLiveSeconds_ - Default Time-To-Live (TTL) for Queue messages in seconds (Optional) + +_timeToLiveDays_ - Default Time-To-Live (TTL) for Queue messages in days (Optional) + +### Authentication Options + _managedIdentityClientId_ - Sets `ManagedIdentityClientId` on `DefaultAzureCredentialOptions`. Requires `serviceUri` _managedIdentityResourceId_ - resourceId for `ManagedIdentityResourceId` on `DefaultAzureCredentialOptions`, do not use together with `ManagedIdentityClientId`. Requires `serviceUri`. @@ -51,6 +57,8 @@ _clientAuthId_ - clientId for `ClientSecretCredential` authentication. Requires _clientAuthSecret_ - clientSecret for `ClientSecretCredential` authentication. Requires `serviceUri`,`tenantIdentity` and `clientAuthId`. +### Proxy Options + _noProxy_ - Bypasses any system proxy and proxy in `ProxyAddress` when set to `true`. _proxyAddress_ - Address of the proxy server to use (e.g. http://proxyserver:8080). @@ -59,11 +67,7 @@ _proxyLogin_ - Login to use for the proxy server. Requires `proxyPassword`. _proxyPassword_ - Password to use for the proxy server. Requires `proxyLogin`. -_useDefaultCredentialsForProxy_ - Uses the default credentials (`System.Net.CredentialCache.DefaultCredentials`) for the proxy server, overriding any values that may have been set in `proxyLogin` and `proxyPassword`. - -_timeToLiveSeconds_ - Default Time-To-Live (TTL) for Queue messages in seconds (Optional) - -_timeToLiveDays_ - Default Time-To-Live (TTL) for Queue messages in days (Optional) +_useDefaultCredentialsForProxy_ - Uses the default credentials (`System.Net.CredentialCache.DefaultCredentials`) for the proxy server. ### Batching Policy diff --git a/src/NLog.Extensions.AzureServiceBus/ICloudServiceBus.cs b/src/NLog.Extensions.AzureServiceBus/ICloudServiceBus.cs index 4960268..228d459 100644 --- a/src/NLog.Extensions.AzureServiceBus/ICloudServiceBus.cs +++ b/src/NLog.Extensions.AzureServiceBus/ICloudServiceBus.cs @@ -3,6 +3,7 @@ using System.Threading; using System.Threading.Tasks; using Azure.Messaging.ServiceBus; +using NLog.Extensions.AzureBlobStorage; namespace NLog.Extensions.AzureStorage { @@ -10,7 +11,7 @@ internal interface ICloudServiceBus { string EntityPath { get; } TimeSpan? DefaultTimeToLive { get; } - void Connect(string connectionString, string queueOrTopicName, string serviceUri, string tenantIdentity, string managedIdentityResourceId, string managedIdentityClientId, string sharedAccessSignature, string storageAccountName, string storageAccountAccessKey, string clientAuthId, string clientAuthSecret, bool useWebSockets, string webSocketProxyAddress, string endPointAddress, TimeSpan? timeToLive); + void Connect(string connectionString, string queueOrTopicName, string serviceUri, string tenantIdentity, string managedIdentityResourceId, string managedIdentityClientId, string sharedAccessSignature, string storageAccountName, string storageAccountAccessKey, string clientAuthId, string clientAuthSecret, string eventProducerIdentifier, bool useWebSockets, string endPointAddress, TimeSpan? timeToLive, ProxySettings proxySettings); Task SendAsync(IEnumerable messages, CancellationToken cancellationToken); Task CloseAsync(); } diff --git a/src/NLog.Extensions.AzureServiceBus/NLog.Extensions.AzureServiceBus.csproj b/src/NLog.Extensions.AzureServiceBus/NLog.Extensions.AzureServiceBus.csproj index 4ab7352..f23a271 100644 --- a/src/NLog.Extensions.AzureServiceBus/NLog.Extensions.AzureServiceBus.csproj +++ b/src/NLog.Extensions.AzureServiceBus/NLog.Extensions.AzureServiceBus.csproj @@ -24,9 +24,9 @@ https://github.com/JDetmar/NLog.Extensions.AzureStorage.git MIT -- Updated Azure.Identity ver. 1.14.2 to fix security issue -- Updated NLog ver. 5.2.5 to support build-triming -- Updated Azure.Messaging.ServiceBus ver. 7.20.1 +- Added support for Proxy-options: ProxyAddress, ProxyLogin, ProxyPassword, NoProxy, UseDefaultCredentialsForProxy +- Added support for Authentication-options: ClientAuthId + ClientAuthSecret +- Added support for EventProducerIdentifier-option Docs: https://github.com/JDetmar/NLog.Extensions.AzureStorage/blob/master/src/NLog.Extensions.AzureServiceBus/README.md @@ -40,6 +40,7 @@ Docs: https://github.com/JDetmar/NLog.Extensions.AzureStorage/blob/master/src/NL + diff --git a/src/NLog.Extensions.AzureServiceBus/README.md b/src/NLog.Extensions.AzureServiceBus/README.md index d76c7a9..0c21eb2 100644 --- a/src/NLog.Extensions.AzureServiceBus/README.md +++ b/src/NLog.Extensions.AzureServiceBus/README.md @@ -37,11 +37,13 @@ ``` -### Parameters +### General Options _name_ - Name of the target. -_connectionString_ - Azure storage connection string. [Layout](https://github.com/NLog/NLog/wiki/Layouts) Required. +_connectionString_ - Azure storage connection string. [Layout](https://github.com/NLog/NLog/wiki/Layouts) Required unless using `ServiceUri`. + +_serviceUri_ - Alternative to ConnectionString, where Managed Identiy is applied from DefaultAzureCredential. _queueName_ - QueueName for multiple producers single consumer. [Layout](https://github.com/NLog/NLog/wiki/Layouts) @@ -67,11 +69,11 @@ _timeToLiveDays_ - Default Time-To-Live (TTL) for ServiceBus messages in days (O _useWebSockets_ - Enable AmqpWebSockets. Ex. true/false (optional) -_webSocketProxyAddress_ - Custom WebProxy address for WebSockets (optional) - _customEndpointAddress_ - Custom endpoint address that can be used when establishing the connection (optional) -_serviceUri_ - Alternative to ConnectionString, where Managed Identiy is applied from DefaultAzureCredential. +_eventProducerIdentifier_ - A unique name used to identify the event producer. If null or empty, a GUID will be used as the identifier (optional) + +### Authentication Options _managedIdentityClientId_ - Sets `ManagedIdentityClientId` on `DefaultAzureCredentialOptions`. Requires `serviceUri`. @@ -89,6 +91,19 @@ _clientAuthId_ - clientId for `ClientSecretCredential` authentication. Requires _clientAuthSecret_ - clientSecret for `ClientSecretCredential` authentication. Requires `serviceUri`,`tenantIdentity` and `clientAuthId`. +### Proxy Options + +_noProxy_ - Bypasses any system proxy and proxy in `ProxyAddress` when set to `true`. Requires `useWebSockets = true`. + +_proxyAddress_ - Address of the proxy server to use (e.g. http://proxyserver:8080). Requires `useWebSockets = true`. + +_proxyLogin_ - Login to use for the proxy server. Requires `proxyPassword`. Requires `useWebSockets = true`. + +_proxyPassword_ - Password to use for the proxy server. Requires `proxyLogin`. Requires `useWebSockets = true`. + +_useDefaultCredentialsForProxy_ - Uses the default credentials (`System.Net.CredentialCache.DefaultCredentials`) for the proxy server. Requires `useWebSockets = true`. + + ### Batching Policy _maxBatchSizeBytes_ - Max size of a single batch in bytes [Integer](https://github.com/NLog/NLog/wiki/Data-types) (Default=256*1024) diff --git a/src/NLog.Extensions.AzureServiceBus/ServiceBusTarget.cs b/src/NLog.Extensions.AzureServiceBus/ServiceBusTarget.cs index c76d8de..8d4380b 100644 --- a/src/NLog.Extensions.AzureServiceBus/ServiceBusTarget.cs +++ b/src/NLog.Extensions.AzureServiceBus/ServiceBusTarget.cs @@ -7,6 +7,7 @@ using Azure.Messaging.ServiceBus; using NLog.Common; using NLog.Config; +using NLog.Extensions.AzureBlobStorage; using NLog.Extensions.AzureStorage; using NLog.Layouts; @@ -182,13 +183,50 @@ public sealed class ServiceBusTarget : AsyncTaskTarget /// /// The proxy to use for communication over web sockets. /// - public Layout WebSocketProxyAddress { get; set; } + [Obsolete("Replaced by ProxyAddress to align with other NLog Targets for Azure")] + public Layout WebSocketProxyAddress { get => ProxyAddress; set => ProxyAddress = value; } /// /// Custom endpoint address that can be used when establishing the connection. /// public Layout CustomEndpointAddress { get; set; } + /// + /// A unique name used to identify the producer. If null or empty, a GUID will be used as the identifier. + /// + public Layout EventProducerIdentifier { get; set; } + + /// + /// Bypasses any system proxy and proxy in when set to . + /// Overrides . + /// + /// Only applies when = + public bool NoProxy { get; set; } + + /// + /// Address of the proxy server to use (e.g. http://proxyserver:8080). + /// + /// Only applies when = + public Layout ProxyAddress { get; set; } + + /// + /// Login to use for the proxy server. Requires . + /// + /// Only applies when = + public Layout ProxyLogin { get; set; } + + /// + /// Password to use for the proxy server. Requires . + /// + /// Only applies when = + public Layout ProxyPassword { get; set; } + + /// + /// Uses the default credentials () for the proxy server, overriding any values that may have been set in and . + /// + /// Only applies when = + public bool UseDefaultCredentialsForProxy { get; set; } + /// /// Gets a list of user properties (aka custom application properties) to add to the AMQP message /// @@ -244,6 +282,7 @@ protected override void InitializeTarget() string useWebSockets = string.Empty; string webSocketProxyAddress = string.Empty; string customEndPointAddress = string.Empty; + string eventProducerIdentifier = string.Empty; var defaultLogEvent = LogEventInfo.CreateNullEvent(); @@ -271,21 +310,32 @@ protected override void InitializeTarget() clientAuthSecret = ClientAuthSecret?.Render(defaultLogEvent); } + eventProducerIdentifier = EventProducerIdentifier?.Render(defaultLogEvent) ?? string.Empty; + + var timeToLive = RenderDefaultTimeToLive(); + if (timeToLive <= TimeSpan.Zero) + { + timeToLive = default(TimeSpan?); + } + useWebSockets = UseWebSockets?.Render(defaultLogEvent) ?? string.Empty; if (!string.IsNullOrEmpty(useWebSockets) && (string.Equals(useWebSockets.Trim(), bool.TrueString, StringComparison.OrdinalIgnoreCase) || string.Equals(useWebSockets.Trim(), "1", StringComparison.OrdinalIgnoreCase))) { useWebSockets = bool.TrueString; } - webSocketProxyAddress = WebSocketProxyAddress?.Render(defaultLogEvent) ?? string.Empty; customEndPointAddress = CustomEndpointAddress?.Render(defaultLogEvent) ?? string.Empty; - var timeToLive = RenderDefaultTimeToLive(); - if (timeToLive <= TimeSpan.Zero) + var proxySettings = new ProxySettings { - timeToLive = default(TimeSpan?); - } + NoProxy = NoProxy, + UseDefaultCredentials = UseDefaultCredentialsForProxy, + Address = ProxyAddress?.Render(defaultLogEvent), + Login = ProxyLogin?.Render(defaultLogEvent), + Password = ProxyPassword?.Render(defaultLogEvent) + }; + proxySettings = proxySettings.RequiresManualProxyConfiguration ? proxySettings : null; - _cloudServiceBus.Connect(connectionString, queueOrTopicName, serviceUri, tenantIdentity, managedIdentityResourceId, managedIdentityClientId, sharedAccessSignature, storageAccountName, storageAccountAccessKey, clientAuthId, clientAuthSecret, bool.TrueString == useWebSockets, webSocketProxyAddress, customEndPointAddress, timeToLive); + _cloudServiceBus.Connect(connectionString, queueOrTopicName, serviceUri, tenantIdentity, managedIdentityResourceId, managedIdentityClientId, sharedAccessSignature, storageAccountName, storageAccountAccessKey, clientAuthId, clientAuthSecret, eventProducerIdentifier, bool.TrueString == useWebSockets, customEndPointAddress, timeToLive, proxySettings); InternalLogger.Debug("AzureServiceBusTarget(Name={0}): Initialized", Name); } catch (Exception ex) @@ -638,18 +688,22 @@ private sealed class CloudServiceBus : ICloudServiceBus public string EntityPath { get; private set; } - public void Connect(string connectionString, string queueOrTopicName, string serviceUri, string tenantIdentity, string managedIdentityResourceId, string managedIdentityClientId, string sharedAccessSignature, string storageAccountName, string storageAccountAccessKey, string clientAuthId, string clientAuthSecret, bool useWebSockets, string webSocketProxyAddress, string endPointAddress, TimeSpan? timeToLive) + public void Connect(string connectionString, string queueOrTopicName, string serviceUri, string tenantIdentity, string managedIdentityResourceId, string managedIdentityClientId, string sharedAccessSignature, string storageAccountName, string storageAccountAccessKey, string clientAuthId, string clientAuthSecret, string eventProducerIdentifier, bool useWebSockets, string endPointAddress, TimeSpan? timeToLive, ProxySettings proxySettings) { EntityPath = queueOrTopicName; DefaultTimeToLive = timeToLive; Azure.Messaging.ServiceBus.ServiceBusClientOptions options = default; - if (useWebSockets || !string.IsNullOrEmpty(webSocketProxyAddress) || !string.IsNullOrEmpty(endPointAddress)) + if (useWebSockets || !string.IsNullOrEmpty(endPointAddress) || !string.IsNullOrEmpty(eventProducerIdentifier)) { options = new Azure.Messaging.ServiceBus.ServiceBusClientOptions(); options.TransportType = useWebSockets ? ServiceBusTransportType.AmqpWebSockets : options.TransportType; - options.WebProxy = !string.IsNullOrEmpty(webSocketProxyAddress) ? new System.Net.WebProxy(webSocketProxyAddress, true) : options.WebProxy; - options.CustomEndpointAddress = !string.IsNullOrEmpty(endPointAddress) ? new Uri(endPointAddress) : options.CustomEndpointAddress; + if (useWebSockets && proxySettings != null) + options.WebProxy = proxySettings.CreateWebProxy(options.WebProxy); + if (!string.IsNullOrEmpty(endPointAddress)) + options.CustomEndpointAddress = new Uri(endPointAddress); + if (!string.IsNullOrEmpty(eventProducerIdentifier)) + options.Identifier = eventProducerIdentifier; } if (string.IsNullOrEmpty(serviceUri)) diff --git a/src/NLog.Extensions.AzureStorage/AzureStorageNameCache.cs b/src/NLog.Extensions.AzureStorage/AzureStorageNameCache.cs index 9a5915b..e183622 100644 --- a/src/NLog.Extensions.AzureStorage/AzureStorageNameCache.cs +++ b/src/NLog.Extensions.AzureStorage/AzureStorageNameCache.cs @@ -74,7 +74,7 @@ Container names must be from 3 through 63 characters long. requestedContainerName = requestedContainerName?.Trim() ?? string.Empty; const string validContainerPattern = "^[a-z0-9](?!.*--)[a-z0-9-]{1,61}[a-z0-9]$"; var loweredRequestedContainerName = requestedContainerName.ToLower(); - if (Regex.Match(loweredRequestedContainerName, validContainerPattern).Success) + if (Regex.Match(loweredRequestedContainerName, validContainerPattern, RegexOptions.ExplicitCapture).Success) { //valid name okay to lower and use return loweredRequestedContainerName; @@ -85,20 +85,19 @@ Container names must be from 3 through 63 characters long. const string trimFobiddenCharactersPattern = "[^a-zA-Z0-9-]"; const string trimExtraHyphensPattern = "-+"; - requestedContainerName = requestedContainerName.Replace('.', '-').Replace('_', '-').Replace('\\', '-').Replace('/', '-').Replace(' ', '-').Trim(new[] { '-' }); - var pass1 = Regex.Replace(requestedContainerName, trimFobiddenCharactersPattern, String.Empty, RegexOptions.None); - var pass2 = Regex.Replace(pass1, trimTrailingPattern, String.Empty, RegexOptions.RightToLeft); - var pass3 = Regex.Replace(pass2, trimLeadingPattern, String.Empty, RegexOptions.None); - var pass4 = Regex.Replace(pass3, trimExtraHyphensPattern, "-", RegexOptions.None); + requestedContainerName = requestedContainerName.Replace('.', '-').Replace('_', '-').Replace('\\', '-').Replace('/', '-').Replace(' ', '-').Replace("--", "-").Replace("--", "-").Trim(new[] { '-' }); + var pass1 = Regex.Replace(requestedContainerName, trimFobiddenCharactersPattern, String.Empty, RegexOptions.ExplicitCapture); + var pass2 = Regex.Replace(pass1, trimTrailingPattern, String.Empty, RegexOptions.RightToLeft | RegexOptions.ExplicitCapture); + var pass3 = Regex.Replace(pass2, trimLeadingPattern, String.Empty, RegexOptions.ExplicitCapture); + var pass4 = Regex.Replace(pass3, trimExtraHyphensPattern, "-", RegexOptions.ExplicitCapture); var loweredCleanedContainerName = pass4.ToLower(); - if (Regex.Match(loweredCleanedContainerName, validContainerPattern).Success) + if (Regex.Match(loweredCleanedContainerName, validContainerPattern, RegexOptions.ExplicitCapture).Success) { return loweredCleanedContainerName; } return "defaultlog"; } - //TODO: update rules /// /// Checks the and repairs table name acording to the Azure naming rules. /// @@ -122,8 +121,8 @@ Table names must be from 3 to 63 characters long. const string trimLeadingPattern = "^.*?(?=[a-zA-Z])"; const string trimFobiddenCharactersPattern = "[^a-zA-Z0-9-]"; - var pass1 = Regex.Replace(tableName, trimFobiddenCharactersPattern, String.Empty, RegexOptions.None); - var cleanedTableName = Regex.Replace(pass1, trimLeadingPattern, String.Empty, RegexOptions.None); + var pass1 = Regex.Replace(tableName, trimFobiddenCharactersPattern, String.Empty, RegexOptions.ExplicitCapture); + var cleanedTableName = Regex.Replace(pass1, trimLeadingPattern, String.Empty, RegexOptions.ExplicitCapture); if (String.IsNullOrWhiteSpace(cleanedTableName) || cleanedTableName.Length > 63 || cleanedTableName.Length < 3) { var tableDefault = "Logs"; diff --git a/src/NLog.Extensions.AzureStorage/ProxyHelpers.cs b/src/NLog.Extensions.AzureStorage/ProxyHelpers.cs index 5c63e42..4634e07 100644 --- a/src/NLog.Extensions.AzureStorage/ProxyHelpers.cs +++ b/src/NLog.Extensions.AzureStorage/ProxyHelpers.cs @@ -38,7 +38,7 @@ public class ProxySettings /// Determines whether a custom proxy is required for the given settings /// /// if a custom proxy is required; otherwise, . - private bool RequiresManualProxyConfiguration => !string.IsNullOrEmpty(Address) || NoProxy || (!string.IsNullOrEmpty(Login) && !string.IsNullOrEmpty(Password)) || UseDefaultCredentials; + public bool RequiresManualProxyConfiguration => !string.IsNullOrEmpty(Address) || NoProxy || (!string.IsNullOrEmpty(Login) && !string.IsNullOrEmpty(Password)) || UseDefaultCredentials; /// /// creates a custom HttpPipelineTransport to be used as for storage targets @@ -50,27 +50,46 @@ public HttpClientTransport CreateHttpClientTransport() { var handler = new HttpClientHandler { - UseProxy = NoProxy != true, - Proxy = NoProxy != true && !string.IsNullOrEmpty(Address) ? CreateProxy(this) : null + UseProxy = !NoProxy, }; - if (handler.Proxy == null && handler.UseProxy) // using default proxy + + if (NoProxy) + { + handler.Proxy = null; + } + else if (!string.IsNullOrEmpty(Address)) + { + handler.Proxy = CreateWebProxy(); + } + else { if (UseDefaultCredentials) handler.DefaultProxyCredentials = CredentialCache.DefaultCredentials; else if (!string.IsNullOrEmpty(Login) && !string.IsNullOrEmpty(Password)) handler.DefaultProxyCredentials = new NetworkCredential(Login, Password); } + return new HttpClientTransport(new HttpClient(handler)); } return null; } - private static WebProxy CreateProxy(ProxySettings proxySettings) + /// + /// Creates new WebProxy-object based on the configured proxy-options. + /// + public IWebProxy CreateWebProxy(IWebProxy defaultProxy = null) { - var proxy = new WebProxy(proxySettings.Address); - if (!string.IsNullOrEmpty(proxySettings.Login) && !string.IsNullOrEmpty(proxySettings.Password)) - proxy.Credentials = new NetworkCredential(proxySettings.Login, proxySettings.Password); + if (NoProxy) + return null; + if (string.IsNullOrEmpty(Address)) + return defaultProxy; + + var proxy = new WebProxy(Address, BypassOnLocal: true); + if (UseDefaultCredentials) + proxy.Credentials = CredentialCache.DefaultCredentials; + else if (!string.IsNullOrEmpty(Login) && !string.IsNullOrEmpty(Password)) + proxy.Credentials = new NetworkCredential(Login, Password); return proxy; } } diff --git a/test/NLog.Extensions.AzureEventHub.Tests/EventHubServiceMock.cs b/test/NLog.Extensions.AzureEventHub.Tests/EventHubServiceMock.cs index 5e67f03..b1a417c 100644 --- a/test/NLog.Extensions.AzureEventHub.Tests/EventHubServiceMock.cs +++ b/test/NLog.Extensions.AzureEventHub.Tests/EventHubServiceMock.cs @@ -1,4 +1,5 @@ using Azure.Messaging.EventHubs; +using NLog.Extensions.AzureBlobStorage; using NLog.Extensions.AzureStorage; using System; using System.Collections.Generic; @@ -23,7 +24,7 @@ public async Task CloseAsync() EventDataSent.Clear(); } - public void Connect(string connectionString, string eventHubName, string serviceUri, string tenantIdentity, string managedIdentityResourceId, string managedIdentityClientId, string sharedAccessSignature, string storageAccountName, string storageAccountAccessKey, string clientAuthId, string clientAuthSecret, bool useWebSockets, string webSocketsProxyAddress, string endPointAddress) + public void Connect(string connectionString, string eventHubName, string serviceUri, string tenantIdentity, string managedIdentityResourceId, string managedIdentityClientId, string sharedAccessSignature, string storageAccountName, string storageAccountAccessKey, string clientAuthId, string clientAuthSecret, string eventProducerIdentifier, bool useWebSockets, string endPointAddress, ProxySettings proxySettings) { ConnectionString = connectionString; EventHubName = eventHubName; diff --git a/test/NLog.Extensions.AzureServiceBus.Tests/ServiceBusMock.cs b/test/NLog.Extensions.AzureServiceBus.Tests/ServiceBusMock.cs index 23e5aab..f7b82b2 100644 --- a/test/NLog.Extensions.AzureServiceBus.Tests/ServiceBusMock.cs +++ b/test/NLog.Extensions.AzureServiceBus.Tests/ServiceBusMock.cs @@ -3,6 +3,7 @@ using System.Text; using System.Threading.Tasks; using Azure.Messaging.ServiceBus; +using NLog.Extensions.AzureBlobStorage; using NLog.Extensions.AzureStorage; namespace NLog.Extensions.AzureServiceBus.Test @@ -31,7 +32,7 @@ public string PeekLastMessageBody() return null; } - public void Connect(string connectionString, string queueOrTopicName, string serviceUri, string tenantIdentity, string managedIdentityResourceId, string managedIdentityClientId, string sharedAccessSignature, string storageAccountName, string storageAccountAccessKey, string clientAuthId, string clientAuthSecret, bool useWebSockets, string webProxy, string endPointAddress, TimeSpan? timeToLive) + public void Connect(string connectionString, string queueOrTopicName, string serviceUri, string tenantIdentity, string managedIdentityResourceId, string managedIdentityClientId, string sharedAccessSignature, string storageAccountName, string storageAccountAccessKey, string clientAuthId, string clientAuthSecret, string eventProducerIdentifier, bool useWebSockets, string endPointAddress, TimeSpan? timeToLive, ProxySettings proxySettings) { ConnectionString = connectionString; EntityPath = queueOrTopicName;