Skip to content

Commit ffa23ee

Browse files
authored
Merge pull request #108 from Jonathan-Walsh-Amey/amey_main
Update CosmosDataSinkExtension.cs to enable support for shared throughput in Cosmos containers
2 parents 9856d71 + 36646c8 commit ffa23ee

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

Extensions/Cosmos/Cosmos.DataTransfer.CosmosExtension/CosmosDataSinkExtension.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public async Task WriteAsync(IAsyncEnumerable<IDataItem> dataItems, IConfigurati
5959
containerProperties.PartitionKeyPath = settings.PartitionKeyPath;
6060
}
6161

62-
ThroughputProperties? throughputProperties = settings.IsServerlessAccount
62+
ThroughputProperties? throughputProperties = settings.IsServerlessAccount || settings.UseSharedThroughput
6363
? null
6464
: settings.UseAutoscaleForCreatedContainer
6565
? ThroughputProperties.CreateAutoscaleThroughput(settings.CreatedContainerMaxThroughput ?? 4000)
@@ -211,4 +211,4 @@ public record ItemResult(string? Id, HttpStatusCode StatusCode)
211211
public int ItemCount => IsSuccess ? 1 : 0;
212212
}
213213
}
214-
}
214+
}

Extensions/Cosmos/Cosmos.DataTransfer.CosmosExtension/CosmosSinkSettings.cs

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public class CosmosSinkSettings : CosmosSettingsBase, IDataExtensionSettings
1313
public int? CreatedContainerMaxThroughput { get; set; }
1414
public bool UseAutoscaleForCreatedContainer { get; set; } = true;
1515
public bool IsServerlessAccount { get; set; } = false;
16+
public bool UseSharedThroughput { get; set; } = false;
1617
public DataWriteMode WriteMode { get; set; } = DataWriteMode.Insert;
1718
public List<string>? PartitionKeyPaths { get; set; }
1819

Extensions/Cosmos/README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Or with RBAC:
4444
}
4545
```
4646

47-
Sink requires an additional `PartitionKeyPath` parameter which is used when creating the container if it does not exist. To use hierarchical partition keys, instead use the `PartitionKeyPaths` setting to supply an array of up to 3 paths. It also supports an optional `RecreateContainer` parameter (`false` by default) to delete and then recreate the container to ensure only newly imported data is present. The optional `BatchSize` parameter (100 by default) sets the number of items to accumulate before inserting. `ConnectionMode` can be set to either `Gateway` (default) or `Direct` to control how the client connects to the CosmosDB service. For situations where a container is created as part of the transfer operation `CreatedContainerMaxThroughput` (in RUs) and `UseAutoscaleForCreatedContainer` provide the initial throughput settings which will be in effect when executing the transfer. The optional `WriteMode` parameter specifies the type of data write to use: `InsertStream`, `Insert`, `UpsertStream`, or `Upsert`. The `IsServerlessAccount` parameter specifies whether the target account uses Serverless instead of Provisioned throughput, which affects the way containers are created. Additional parameters allow changing the behavior of the Cosmos client appropriate to your environment.
47+
Sink requires an additional `PartitionKeyPath` parameter which is used when creating the container if it does not exist. To use hierarchical partition keys, instead use the `PartitionKeyPaths` setting to supply an array of up to 3 paths. It also supports an optional `RecreateContainer` parameter (`false` by default) to delete and then recreate the container to ensure only newly imported data is present. The optional `BatchSize` parameter (100 by default) sets the number of items to accumulate before inserting. `ConnectionMode` can be set to either `Gateway` (default) or `Direct` to control how the client connects to the CosmosDB service. For situations where a container is created as part of the transfer operation `CreatedContainerMaxThroughput` (in RUs) and `UseAutoscaleForCreatedContainer` provide the initial throughput settings which will be in effect when executing the transfer. To instead use shared throughput that has been provisioned at the database level, set the `UseSharedThroughput` parameter to `true`. The optional `WriteMode` parameter specifies the type of data write to use: `InsertStream`, `Insert`, `UpsertStream`, or `Upsert`. The `IsServerlessAccount` parameter specifies whether the target account uses Serverless instead of Provisioned throughput, which affects the way containers are created. Additional parameters allow changing the behavior of the Cosmos client appropriate to your environment.
4848

4949
### Sink
5050

@@ -62,6 +62,7 @@ Sink requires an additional `PartitionKeyPath` parameter which is used when crea
6262
"CreatedContainerMaxThroughput": 1000,
6363
"UseAutoscaleForCreatedContainer": true,
6464
"WriteMode": "InsertStream",
65-
"IsServerlessAccount": false
65+
"IsServerlessAccount": false,
66+
"UseSharedThroughput": false
6667
}
6768
```

0 commit comments

Comments
 (0)