Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions ExampleConfigs.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,24 @@
]
}
```

## JSON to Cosmos-NoSQL (Using Authenticated Proxy)

```json
{
"Source": "json",
"Sink": "cosmos-nosql",
"SourceSettings": {
"FilePath": "c:\\data\\sales-data.json"
},
"SinkSettings": {
"ConnectionString": "AccountEndpoint=https://...",
"Database": "myDb",
"Container": "myContainer",
"PartitionKeyPath": "/id",
"WriteMode": "Insert",
"WebProxy": "http://yourproxy.server.com/",
"UseDefaultProxyCredentials": true
}
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -209,4 +209,31 @@ public void GetValidationErrors_WhenRbacWithoutInitClientEncryption_Succeeds()

Assert.AreEqual(0, validationErrors.Count());
}

[TestMethod]
public void UseDefaultProxyCredentials_DefaultsToFalse()
{
var settings = new CosmosSinkSettings
{
ConnectionString = "AccountEndpoint=https://localhost:8081/;AccountKey=",
Database = "db",
Container = "container",
};

Assert.IsFalse(settings.UseDefaultProxyCredentials);
}

[TestMethod]
public void UseDefaultProxyCredentials_CanBeSetToTrue()
{
var settings = new CosmosSinkSettings
{
ConnectionString = "AccountEndpoint=https://localhost:8081/;AccountKey=",
Database = "db",
Container = "container",
UseDefaultProxyCredentials = true,
};

Assert.IsTrue(settings.UseDefaultProxyCredentials);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,31 @@ public void Validate_WithAccountEndpoint_Succeeds()

settings.Validate();
}

[TestMethod]
public void UseDefaultProxyCredentials_DefaultsToFalse()
{
var settings = new CosmosSourceSettings
{
ConnectionString = "AccountEndpoint=https://localhost:8081/;AccountKey=",
Database = "db",
Container = "container",
};

Assert.IsFalse(settings.UseDefaultProxyCredentials);
}

[TestMethod]
public void UseDefaultProxyCredentials_CanBeSetToTrue()
{
var settings = new CosmosSourceSettings
{
ConnectionString = "AccountEndpoint=https://localhost:8081/;AccountKey=",
Database = "db",
Container = "container",
UseDefaultProxyCredentials = true,
};

Assert.IsTrue(settings.UseDefaultProxyCredentials);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ public static CosmosClient CreateClient(CosmosSettingsBase settings, string disp
};

if (!string.IsNullOrEmpty(settings.WebProxy)){
clientOptions.WebProxy = new WebProxy(settings.WebProxy);
var webProxy = new WebProxy(settings.WebProxy);
if (settings.UseDefaultProxyCredentials)
{
webProxy.UseDefaultCredentials = true;
}
clientOptions.WebProxy = webProxy;
}

CosmosClient? cosmosClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public abstract class CosmosSettingsBase : IValidatableObject
public string? Container { get; set; }
public ConnectionMode ConnectionMode { get; set; } = ConnectionMode.Gateway;
public string? WebProxy { get; set; }
public bool UseDefaultProxyCredentials { get; set; } = false;
public bool UseRbacAuth { get; set; }
public string? AccountEndpoint { get; set; }
public bool EnableInteractiveCredentials { get; set; }
Expand Down
18 changes: 14 additions & 4 deletions Extensions/Cosmos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ 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. An optional `WebProxy` parameter (`null` by default) enables connections through a proxy.
Source supports the following optional parameters:
- `IncludeMetadataFields` (`false` by default) - Enables inclusion of built-in Cosmos fields prefixed with `"_"`, for example `"_etag"` and `"_ts"`.
- `PartitionKeyValue` - Allows for filtering to a single partition.
- `Query` - Allows further filtering using a Cosmos SQL statement.
- `WebProxy` (`null` by default) - Enables connections through a proxy.
- `UseDefaultProxyCredentials` (`false` by default) - When `true`, includes default credentials in the proxy request. Use this when connecting through an authenticated proxy that returns `407 Proxy Authentication Required`.
Comment thread
philnach marked this conversation as resolved.
Outdated

### Always Encrypted

Expand All @@ -36,7 +41,8 @@ The extension will also automatically handle the encryption keys and encryption
"IncludeMetadataFields": false,
"PartitionKeyValue":"123",
"Query":"SELECT * FROM c WHERE c.category='event'",
"WebProxy":"http://yourproxy.server.com/"
"WebProxy":"http://yourproxy.server.com/",
"UseDefaultProxyCredentials": true
}
```

Expand All @@ -52,8 +58,9 @@ Or with RBAC:
"IncludeMetadataFields": false,
"PartitionKeyValue":"123",
"Query":"SELECT * FROM c WHERE c.category='event'",
"InitClientEncryption": false
"WebProxy":"http://yourproxy.server.com/"
"InitClientEncryption": false,
"WebProxy":"http://yourproxy.server.com/",
"UseDefaultProxyCredentials": true
}
```

Expand Down Expand Up @@ -85,6 +92,9 @@ Or with RBAC:
- `Gateway` (default)
- `Direct`

- **`WebProxy`**: Optional. Specifies the proxy server URL to use for connections (e.g., `http://yourproxy.server.com/`).
- **`UseDefaultProxyCredentials`**: Optional, defaults to `false`. When `true`, includes default credentials in the proxy request. Use this when connecting through an authenticated proxy that returns `407 Proxy Authentication Required`.

- **`LimitToEndpoint`**: Optional, defaults to `false`. When the value of this property is false, the Cosmos DB SDK will automatically discover
write and read regions, and use them when the configured application region is not available.
When set to `true`, availability is limited to the endpoint specified.
Expand Down
Loading