Skip to content

Commit c306799

Browse files
authored
Merge pull request #133 from admsteck/feature/add-proxy-support-to-cosmos
Add proxy support to the Cosmos Extension
2 parents 3fc3f32 + 55662ea commit c306799

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

Extensions/Cosmos/Cosmos.DataTransfer.CosmosExtension/CosmosExtensionServices.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Reflection;
77
using Azure.Core;
88
using System.Text.RegularExpressions;
9+
using System.Net;
910

1011
namespace Cosmos.DataTransfer.CosmosExtension
1112
{
@@ -31,6 +32,10 @@ public static CosmosClient CreateClient(CosmosSettingsBase settings, string disp
3132
EnableContentResponseOnWrite = false,
3233
Serializer = cosmosSerializer,
3334
};
35+
36+
if (!string.IsNullOrEmpty(settings.WebProxy)){
37+
clientOptions.WebProxy = new WebProxy(settings.WebProxy);
38+
}
3439

3540
CosmosClient? cosmosClient;
3641
if (settings.UseRbacAuth)

Extensions/Cosmos/Cosmos.DataTransfer.CosmosExtension/CosmosSettingsBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public abstract class CosmosSettingsBase : IValidatableObject
1111
[Required]
1212
public string? Container { get; set; }
1313
public ConnectionMode ConnectionMode { get; set; } = ConnectionMode.Gateway;
14-
14+
public string? WebProxy { get; set; }
1515
public bool UseRbacAuth { get; set; }
1616
public string? AccountEndpoint { get; set; }
1717
public bool EnableInteractiveCredentials { get; set; } = true;

Extensions/Cosmos/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Source and sink settings also both require parameters to specify the data locati
1414
- `Database`
1515
- `Container`
1616

17-
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.
17+
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.
1818

1919
### Source
2020

@@ -25,7 +25,8 @@ Source supports an optional `IncludeMetadataFields` parameter (`false` by defaul
2525
"Container":"myContainer",
2626
"IncludeMetadataFields": false,
2727
"PartitionKeyValue":"123",
28-
"Query":"SELECT * FROM c WHERE c.category='event'"
28+
"Query":"SELECT * FROM c WHERE c.category='event'",
29+
"WebProxy":"http://yourproxy.server.com/"
2930
}
3031
```
3132

@@ -40,7 +41,8 @@ Or with RBAC:
4041
"Container":"myContainer",
4142
"IncludeMetadataFields": false,
4243
"PartitionKeyValue":"123",
43-
"Query":"SELECT * FROM c WHERE c.category='event'"
44+
"Query":"SELECT * FROM c WHERE c.category='event'",
45+
"WebProxy":"http://yourproxy.server.com/"
4446
}
4547
```
4648

0 commit comments

Comments
 (0)