From e4ca5dca8c3cd20bb2a06bec509227a01542d9c0 Mon Sep 17 00:00:00 2001 From: "Stechschulte, Adam M" Date: Fri, 7 Jun 2024 11:21:25 -0400 Subject: [PATCH 1/2] Add proxy support to the Cosmos Extension --- .../CosmosExtensionServices.cs | 5 +++++ .../CosmosSettingsBase.cs | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Extensions/Cosmos/Cosmos.DataTransfer.CosmosExtension/CosmosExtensionServices.cs b/Extensions/Cosmos/Cosmos.DataTransfer.CosmosExtension/CosmosExtensionServices.cs index 664029e..f3fe7d2 100644 --- a/Extensions/Cosmos/Cosmos.DataTransfer.CosmosExtension/CosmosExtensionServices.cs +++ b/Extensions/Cosmos/Cosmos.DataTransfer.CosmosExtension/CosmosExtensionServices.cs @@ -6,6 +6,7 @@ using System.Reflection; using Azure.Core; using System.Text.RegularExpressions; +using System.Net; namespace Cosmos.DataTransfer.CosmosExtension { @@ -31,6 +32,10 @@ public static CosmosClient CreateClient(CosmosSettingsBase settings, string disp EnableContentResponseOnWrite = false, Serializer = cosmosSerializer, }; + + if (!string.IsNullOrEmpty(settings.WebProxy)){ + clientOptions.WebProxy = new WebProxy(settings.WebProxy); + } CosmosClient? cosmosClient; if (settings.UseRbacAuth) diff --git a/Extensions/Cosmos/Cosmos.DataTransfer.CosmosExtension/CosmosSettingsBase.cs b/Extensions/Cosmos/Cosmos.DataTransfer.CosmosExtension/CosmosSettingsBase.cs index 74fb17e..e074ac2 100644 --- a/Extensions/Cosmos/Cosmos.DataTransfer.CosmosExtension/CosmosSettingsBase.cs +++ b/Extensions/Cosmos/Cosmos.DataTransfer.CosmosExtension/CosmosSettingsBase.cs @@ -11,7 +11,7 @@ public abstract class CosmosSettingsBase : IValidatableObject [Required] public string? Container { get; set; } public ConnectionMode ConnectionMode { get; set; } = ConnectionMode.Gateway; - + public string? WebProxy { get; set; } public bool UseRbacAuth { get; set; } public string? AccountEndpoint { get; set; } public bool EnableInteractiveCredentials { get; set; } = true; From 55662ea42b69f233b0d656ea9a339fed67746cac Mon Sep 17 00:00:00 2001 From: "Stechschulte, Adam M" Date: Wed, 24 Jul 2024 08:29:03 -0400 Subject: [PATCH 2/2] Add WebProxy to readme for Cosmos extension --- Extensions/Cosmos/README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Extensions/Cosmos/README.md b/Extensions/Cosmos/README.md index b3b9de2..dc8b60d 100644 --- a/Extensions/Cosmos/README.md +++ b/Extensions/Cosmos/README.md @@ -14,7 +14,7 @@ Source and sink settings also both require parameters to specify the data locati - `Database` - `Container` -Source supports an optional `IncludeMetadataFields` parameter (`false` by default) to enable inclusion of built-in Cosmos fields prefixed with `"_"`, for example `"_etag"` and `"_ts"`. An optional PartitionKeyValue setting allows for filtering to a single partition. The optional Query setting allows further filtering using a Cosmos SQL statement. +Source supports an optional `IncludeMetadataFields` parameter (`false` by default) to enable inclusion of built-in Cosmos fields prefixed with `"_"`, for example `"_etag"` and `"_ts"`. An optional PartitionKeyValue setting allows for filtering to a single partition. The optional Query setting allows further filtering using a Cosmos SQL statement. An optional `WebProxy` parameter (`null` by default) enables connections through a proxy. ### Source @@ -25,7 +25,8 @@ Source supports an optional `IncludeMetadataFields` parameter (`false` by defaul "Container":"myContainer", "IncludeMetadataFields": false, "PartitionKeyValue":"123", - "Query":"SELECT * FROM c WHERE c.category='event'" + "Query":"SELECT * FROM c WHERE c.category='event'", + "WebProxy":"http://yourproxy.server.com/" } ``` @@ -40,7 +41,8 @@ Or with RBAC: "Container":"myContainer", "IncludeMetadataFields": false, "PartitionKeyValue":"123", - "Query":"SELECT * FROM c WHERE c.category='event'" + "Query":"SELECT * FROM c WHERE c.category='event'", + "WebProxy":"http://yourproxy.server.com/" } ```