Class CosmosDestination<TInput>
A data flow destination for inserting data into a couchbase bucket.
Inheritance
CosmosDestination<TInput>
Namespace: ETLBox.Azure.CosmosDb
Assembly: ETLBox.Azure.CosmosDb.dll
Syntax
public class CosmosDestination<TInput> : DataFlowBatchDestination<TInput>, IDataFlowLogging, IDataFlowBatchDestination<TInput>, IDataFlowDestination<TInput>, IDataFlowBatchDestination, IDataFlowDestination, IDataFlowComponent, ILoggableTask
Type Parameters
Name | Description |
---|
TInput | Type of ingoing data. |
Constructors
CosmosDestination()
Declaration
public CosmosDestination()
CosmosDestination(int)
Declaration
public CosmosDestination(int batchSize)
Parameters
Type | Name | Description |
---|
int | batchSize | |
CosmosDestination(string, string, string)
Declaration
public CosmosDestination(string connectionString, string databaseName, string containerName)
Parameters
Properties
AccountEndpoint
Declaration
public string AccountEndpoint { get; set; }
Property Value
AuthKeyOrResourceToken
Declaration
public string AuthKeyOrResourceToken { get; set; }
Property Value
AzureKeyCredential
Optional: An Azure Key Credential used when opening the connection
(works only in combination with ConnectionString)
Declaration
public AzureKeyCredential AzureKeyCredential { get; set; }
Property Value
AzureTokenCredential
Optional: An Azure Token Credential used when opening the connection
(works only in combination with ConnectionString)
Declaration
public TokenCredential AzureTokenCredential { get; set; }
Property Value
ConnectionString
Declaration
public string ConnectionString { get; set; }
Property Value
ContainerName
The container name of the Azure Cosmos Db destination
Declaration
public string ContainerName { get; set; }
Property Value
CosmosClient
Optional: Instead of providing the ConnectionString and/or other credentials, you can also create
the CosmosClient manually in your code and assign it to this property. This client will then be used,
and no new client won't be created.
Please make sure bulk insert is allowed in the client.
Declaration
public CosmosClient CosmosClient { get; set; }
Property Value
DatabaseName
The database name of the Azure Cosmos Db destination
Declaration
public string DatabaseName { get; set; }
Property Value
SetItemActionOptions
By default, all data is created/inserted into the destination.
For each record, you can influcene the item action (e.g. to change it to upsert, replace or delete).
Replace and Delete will need to set a partition key for each record via the SetItemActionOptions.
For Delete you will also need to set an id to identify the record to be deleted.
Declaration
public Action<ItemActionOption, TInput> SetItemActionOptions { get; set; }
Property Value
Examples
dest.SetItemActionOptions = (options, item) => {
options.ItemAction = ItemAction.Delete; //or ItemAction.Replace or ItemAction.Upsert
options.Id = item.Id; //only for Deletes
options.PartitionKey = new PartitionKey(item.PartitionKey);
};
TaskName
A name to identify the task or component. Every component or task comes
with a default name that can be overwritten.
Declaration
public override string TaskName { get; set; }
Property Value
Overrides
UseTransactionalBatch
By default, data is inserted as bulk. If you prefer to insert data as part of a transactional batch, set this property to true.
The maximum allowed batch size is then 100 (due to the limitation of Cosmos Db).
This works best if all data has the same partition key. If the incoming data has different partition keys, the data is inserted
in multiple batches, grouped by each partition key.
Make sure to add a partition key for each record using the SetItemActionOptions action.
If any of the records in the batch is flawed, the whole batch will not be inserted.
You can redirect erroneous batches using 'LinkErrorsTo()' when linking your components.
Declaration
public bool UseTransactionalBatch { get; set; }
Property Value
Examples
dest.UseTransactionalBatch = true;
dest.SetItemActionOptions = (config, item) => config.PartitionKey = new PartitionKey(item.Block);
Methods
BulkInsertData(TInput[])
Declaration
protected override void BulkInsertData(TInput[] data)
Parameters
Type | Name | Description |
---|
TInput[] | data | |
Overrides
CheckParameter()
Declaration
protected override void CheckParameter()
Overrides
FinishWrite()
Declaration
protected override void FinishWrite()
Overrides
PrepareParameter()
Declaration
protected override void PrepareParameter()
Overrides
PrepareWrite()
Declaration
protected override void PrepareWrite()
Overrides
Implements