diff --git a/Extensions/Cosmos/Cosmos.DataTransfer.CosmosExtension.UnitTests/CosmosSettingsBaseTests.cs b/Extensions/Cosmos/Cosmos.DataTransfer.CosmosExtension.UnitTests/CosmosSettingsBaseTests.cs
index 6ca5f34..35c8263 100644
--- a/Extensions/Cosmos/Cosmos.DataTransfer.CosmosExtension.UnitTests/CosmosSettingsBaseTests.cs
+++ b/Extensions/Cosmos/Cosmos.DataTransfer.CosmosExtension.UnitTests/CosmosSettingsBaseTests.cs
@@ -21,5 +21,27 @@ public void AllowBulkExecution_Property_ShouldSetAndGet()
settings.AllowBulkExecution = false;
Assert.IsFalse(settings.AllowBulkExecution, "AllowBulkExecution should be false when set to false");
}
+
+ [TestMethod]
+ public void EnableContentResponseOnWrite_Property_ShouldSetAndGet()
+ {
+ var settings = new TestableCosmosSettings
+ {
+ EnableContentResponseOnWrite = false
+ };
+
+ Assert.IsFalse(settings.EnableContentResponseOnWrite, "EnableContentResponseOnWrite should be false when set to false");
+
+ settings.EnableContentResponseOnWrite = true;
+ Assert.IsTrue(settings.EnableContentResponseOnWrite, "EnableContentResponseOnWrite should be true when set to true");
+ }
+
+ [TestMethod]
+ public void EnableContentResponseOnWrite_Property_ShouldDefaultToTrue()
+ {
+ var settings = new TestableCosmosSettings();
+
+ Assert.IsTrue(settings.EnableContentResponseOnWrite, "EnableContentResponseOnWrite should default to true");
+ }
}
}
diff --git a/Extensions/Cosmos/Cosmos.DataTransfer.CosmosExtension/CosmosExtensionServices.cs b/Extensions/Cosmos/Cosmos.DataTransfer.CosmosExtension/CosmosExtensionServices.cs
index c158a08..081c02d 100644
--- a/Extensions/Cosmos/Cosmos.DataTransfer.CosmosExtension/CosmosExtensionServices.cs
+++ b/Extensions/Cosmos/Cosmos.DataTransfer.CosmosExtension/CosmosExtensionServices.cs
@@ -52,8 +52,8 @@ public static CosmosClient CreateClient(CosmosSettingsBase settings, string disp
{
ConnectionMode = settings.ConnectionMode,
ApplicationName = userAgentString,
- AllowBulkExecution = true,
- EnableContentResponseOnWrite = false,
+ AllowBulkExecution = settings.AllowBulkExecution,
+ EnableContentResponseOnWrite = settings.EnableContentResponseOnWrite,
Serializer = cosmosSerializer,
LimitToEndpoint = settings.LimitToEndpoint,
};
diff --git a/Extensions/Cosmos/Cosmos.DataTransfer.CosmosExtension/CosmosSettingsBase.cs b/Extensions/Cosmos/Cosmos.DataTransfer.CosmosExtension/CosmosSettingsBase.cs
index d147ec0..eea4c29 100644
--- a/Extensions/Cosmos/Cosmos.DataTransfer.CosmosExtension/CosmosSettingsBase.cs
+++ b/Extensions/Cosmos/Cosmos.DataTransfer.CosmosExtension/CosmosSettingsBase.cs
@@ -47,6 +47,27 @@ public abstract class CosmosSettingsBase : IValidatableObject
///
public bool AllowBulkExecution { get; set; } = false;
+ ///
+ /// Gets or sets whether to only return headers and status code in the Cosmos DB response
+ /// for write item operations like Create, Upsert, Patch and Replace.
+ /// Setting to false will cause the response to have a null resource,
+ /// reducing networking and CPU load by not sending the resource back over the network
+ /// and serializing it on the client.
+ ///
+ /// This setting applies to sink (write) operations.
+ ///
+ ///
+ /// Default: true
+ ///
+ ///
+ /// For more information, see
+ ///
+ /// CosmosClientOptions.EnableContentResponseOnWrite Property
+ ///
+ ///
+ ///
+ public bool EnableContentResponseOnWrite { get; set; } = true;
+
public virtual IEnumerable Validate(ValidationContext validationContext)
{
if (!UseRbacAuth && string.IsNullOrEmpty(ConnectionString))
diff --git a/Extensions/Cosmos/README.md b/Extensions/Cosmos/README.md
index 58b68bf..e555e2b 100644
--- a/Extensions/Cosmos/README.md
+++ b/Extensions/Cosmos/README.md
@@ -41,9 +41,10 @@ These properties will be preserved exactly as they appear in the source when mig
| Container | Cosmos DB container name | |
| WebProxy | Proxy server URL for Cosmos DB connections | |
| InitClientEncryption | Enable Always Encrypted feature | false |
-| LimitToEndpoint | Restrict client to endpoint (see CosmosClientOptions.LimitToEndpoint) | false |
+| LimitToEndpoint | Restrict client to endpoint. See [CosmosClientOptions.LimitToEndpoint Property](https://learn.microsoft.com/dotnet/api/microsoft.azure.cosmos.cosmosclientoptions.limittoendpoint) | false |
| DisableSslValidation | Disable SSL certificate validation (for local dev only; not for production) | false |
| AllowBulkExecution | Enable bulk execution for optimized performance.
**Warning:** May affect consistency and error handling. | false |
+| EnableContentResponseOnWrite | Return only headers and status code (not response body) for write operations to reduce network IO. Applies to sink operations. See [CosmosClientOptions.EnableContentResponseOnWrite Property](https://learn.microsoft.com/dotnet/api/microsoft.azure.cosmos.cosmosclientoptions.enablecontentresponseonwrite) | true |
Source and sink require settings used to locate and access the Cosmos DB account. This can be done in one of two ways:
@@ -66,6 +67,25 @@ Example:
}
```
+### Content Response On Write
+
+The `EnableContentResponseOnWrite` setting controls whether the full response body is returned for write operations (Create, Upsert, Patch, Replace). When set to `false`, only headers and status code are returned, which can drastically reduce network IO and improve performance. This is especially beneficial for high-throughput scenarios where the response body is not needed. Default is `true`.
+
+**Note**: This setting applies to sink (write) operations.
+
+For more information, see [CosmosClientOptions.EnableContentResponseOnWrite Property](https://learn.microsoft.com/dotnet/api/microsoft.azure.cosmos.cosmosclientoptions.enablecontentresponseonwrite).
+
+Example:
+
+```json
+{
+ "ConnectionString": "AccountEndpoint=https://...",
+ "Database": "myDb",
+ "Container": "myContainer",
+ "EnableContentResponseOnWrite": false
+}
+```
+
Source and sink settings also both require parameters to specify the data location within a Cosmos DB account:
- `Database`
@@ -76,7 +96,7 @@ Source supports the following optional parameters:
- `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 WebProxy request. Use this when connecting through an authenticated proxy that returns [`407 Proxy Authentication Required`](https://learn.microsoft.com/dotnet/api/system.net.webproxy.credentials?view=net-10.0#remarks).
+- `UseDefaultProxyCredentials` (`false` by default) - When `true`, includes default credentials in the WebProxy request. Use this when connecting through an authenticated proxy that returns `407 Proxy Authentication Required`. See [WebProxy.Credentials Property](https://learn.microsoft.com/dotnet/api/system.net.webproxy.credentials).
- `UseDefaultCredentials` (`false` by default) - When `true`, configures the underlying HttpClient with default network credentials. Use this when the connection to CosmosDB requires authentication through a proxy.
- `PreAuthenticate` (`false` by default) - When `true`, enables pre-authentication on the HttpClient, which sends credentials with the initial request rather than waiting for a 401/407 challenge. This can save extra round-trips but should only be used when the endpoint is trusted.
@@ -172,14 +192,14 @@ For development purposes with SSL validation disabled:
- `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 WebProxy request. Use this when connecting through an authenticated proxy that returns [`407 Proxy Authentication Required`](https://learn.microsoft.com/dotnet/api/system.net.webproxy.credentials?view=net-10.0#remarks).
+- **`UseDefaultProxyCredentials`**: Optional, defaults to `false`. When `true`, includes default credentials in the WebProxy request. Use this when connecting through an authenticated proxy that returns `407 Proxy Authentication Required`. See [WebProxy.Credentials Property](https://learn.microsoft.com/dotnet/api/system.net.webproxy.credentials).
- **`UseDefaultCredentials`**: Optional, defaults to `false`. When `true`, configures the underlying HttpClient with default network credentials. Use this when the connection to CosmosDB requires authentication through a proxy.
- **`PreAuthenticate`**: Optional, defaults to `false`. When `true`, enables pre-authentication on the HttpClient, which sends credentials with the initial request rather than waiting for a 401/407 challenge. This can save extra round-trips but should only be used when the endpoint is trusted.
- **`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.
- - **Note**: [CosmosClientOptions.LimitToEndpoint Property](https://learn.microsoft.com/dotnet/api/microsoft.azure.cosmos.cosmosclientoptions.limittoendpoint?view=azure-dotnet). When using the Cosmos DB Emulator Container for Linux it's been observed
+ - **Note**: [CosmosClientOptions.LimitToEndpoint Property](https://learn.microsoft.com/dotnet/api/microsoft.azure.cosmos.cosmosclientoptions.limittoendpoint). When using the Cosmos DB Emulator Container for Linux it has been observed
setting the value to `true` enables import and export of data.
#### **SSL/Certificate Settings**