---
title: "Add ETL Operation"
url: "https://docs.ravendb.net/6.2/client-api/operations/maintenance/etl/add-etl"
version: "6.2"
language: "csharp"
---

# Add ETL Operation

> Client language: C#. Also available for [Java](https://docs.ravendb.net/6.2/client-api/operations/maintenance/etl/add-etl.java.md), [Node.js](https://docs.ravendb.net/6.2/client-api/operations/maintenance/etl/add-etl.nodejs.md).
>
> RavenDB publishes an official agent skill for coding assistants at https://docs.ravendb.net/skills/ravendb/SKILL.md (also installable with `npx skills add ravendb/skills`). The skill describes itself as: "Read this before writing any RavenDB query, client call or /databases/ request. Covers server setup, document modelling, the Node.js, .NET and Python clients, RQL, indexes, vector search and AI agents. Code written from recall tends to run and return the wrong rows, because RQL resembles SQL and the clients take field names as plain strings."

> **Note**
>
> - Use the `AddEtlOperation` method to add a new ongoing ETL task to your database.
>
> - To learn about ETL (Extract, Transfer, Load) ongoing tasks, see article [ETL Basics](https://docs.ravendb.net/6.2/server/ongoing-tasks/etl/basics.md).  
>   To learn how to manage ETL tasks from the Studio, see [Ongoing tasks - overview](https://docs.ravendb.net/6.2/studio/database/tasks/ongoing-tasks/general-info.md).
>
> - In this page:
>
>   - [Add RavenDB ETL task](#add-ravendb-etl-task)
>   - [Add SQL ETL task](#add-sql-etl-task)
>   - [Add OLAP ETL task](#add-olap-etl-task)
>   - [Add Elasticsearch ETL task](#add-elasticsearch-etl-task)
>   - [Add Kafka ETL task](#add-kafka-etl-task)
>   - [Add RabbitMQ ETL task](#add-rabbitmq-etl-task)
>   - [Add Azure Queue Storage ETL task](#add-azure-queue-storage-etl-task)
>   - [Syntax](#syntax)

## Add RavenDB ETL task

- Learn about the RavenDB ETL task in article **[RavenDB ETL task](https://docs.ravendb.net/6.2/server/ongoing-tasks/etl/raven.md)**.
- Learn how to define a connection string for the RavenDB ETL task in section **[Add a RavenDB connection string](https://docs.ravendb.net/6.2/client-api/operations/maintenance/connection-strings/add-connection-string.md#add-a-ravendb-connection-string)**.
- To manage the RavenDB ETL task from the Studio, see **[Studio: RavenDB ETL task](https://docs.ravendb.net/6.2/studio/database/tasks/ongoing-tasks/ravendb-etl-task.md)**.
  The following example adds a RavenDB ETL task:

```csharp
// Define the RavenDB ETL task configuration object
// ================================================
var ravenEtlConfig = new RavenEtlConfiguration
{
  Name = "task-name",
  ConnectionStringName = "raven-connection-string-name",
  Transforms =
  {
      new Transformation
      {
          // The script name
          Name = "script-name",
          
          // RavenDB collections the script uses
          Collections = { "Employees" },
          
          // The transformation script
          Script = @"loadToEmployees ({
                     Name: this.FirstName + ' ' + this.LastName,
                     Title: this.Title
                   });"
      }
  },

  // Do not prevent task failover to another node (optional) 
  PinToMentorNode = false
};

// Define the AddEtlOperation
// ==========================
var operation = new AddEtlOperation<RavenConnectionString>(ravenEtlConfig);

// Execute the operation by passing it to Maintenance.Send
// =======================================================
AddEtlOperationResult result = store.Maintenance.Send(operation);
```

## Add SQL ETL task

- Learn about the SQL ETL task in article **[SQL ETL task](https://docs.ravendb.net/6.2/server/ongoing-tasks/etl/sql.md)**.
- Learn how to define a connection string for the SQL ETL task in section **[Add a SQL connection string](https://docs.ravendb.net/6.2/client-api/operations/maintenance/connection-strings/add-connection-string.md#add-an-sql-connection-string)**.
  The following example adds an SQL ETL task:

```csharp
// Define the SQL ETL task configuration object
// ============================================
var sqlEtlConfig = new SqlEtlConfiguration
{
  Name = "task-name",
  ConnectionStringName = "sql-connection-string-name",
  SqlTables =
  {
      new SqlEtlTable {TableName = "Orders", DocumentIdColumn = "Id", InsertOnlyMode = false},
      new SqlEtlTable {TableName = "OrderLines", DocumentIdColumn = "OrderId", InsertOnlyMode = false},
  },
  Transforms =
  {
      new Transformation
      {
          Name = "script-name",
          Collections = { "Orders" },
          Script = @"var orderData = {
                              Id: id(this),
                              OrderLinesCount: this.Lines.length,
                              TotalCost: 0
                          };

                          for (var i = 0; i < this.Lines.length; i++) {
                              var line = this.Lines[i];
                              orderData.TotalCost += line.PricePerUnit;
                              
                              // Load to SQL table 'OrderLines'
                              loadToOrderLines({
                                  OrderId: id(this),
                                  Qty: line.Quantity,
                                  Product: line.Product,
                                  Cost: line.PricePerUnit
                              });
                          }
                          orderData.TotalCost = Math.round(orderData.TotalCost  * 100) / 100;

                          // Load to SQL table 'Orders'
                          loadToOrders(orderData)"
      }
  },

  // Do not prevent task failover to another node (optional) 
  PinToMentorNode = false
};

// Define the AddEtlOperation
// ===========================
var operation = new AddEtlOperation<SqlConnectionString>(sqlEtlConfig);

// Execute the operation by passing it to Maintenance.Send
// =======================================================
AddEtlOperationResult result = store.Maintenance.Send(operation);
```

## Add OLAP ETL task

- Learn about the OLAP ETL task in article **[OLAP ETL task](https://docs.ravendb.net/6.2/server/ongoing-tasks/etl/olap.md)**.
- Learn how to define a connection string for the OLAP ETL task in section **[Add an OLAP connection string](https://docs.ravendb.net/6.2/client-api/operations/maintenance/connection-strings/add-connection-string.md#add-an-olap-connection-string)**.
- To manage the OLAP ETL task from the Studio, see **[Studio: OLAP ETL task](https://docs.ravendb.net/6.2/studio/database/tasks/ongoing-tasks/olap-etl-task.md)**.
  The following example adds an OLAP ETL task:

```csharp
// Define the OLAP ETL task configuration object
// =============================================
var olapEtlConfig = new OlapEtlConfiguration
{
  Name = "task-name",
  ConnectionStringName = "olap-connection-string-name",
  Transforms =
  {
      new Transformation
      {
          Name = "script-name",
          Collections = {"Orders"},
          Script = @"var orderDate = new Date(this.OrderedAt);
                         var year = orderDate.getFullYear();
                         var month = orderDate.getMonth();
                         var key = new Date(year, month);
                         loadToOrders(key, {
                             Company : this.Company,
                             ShipVia : this.ShipVia
                         })"
      }
  }
};

// Define the AddEtlOperation
// ==========================
var operation = new AddEtlOperation<OlapConnectionString>(olapEtlConfig);

// Execute the operation by passing it to Maintenance.Send
// =======================================================
AddEtlOperationResult result = store.Maintenance.Send(operation);
```

## Add Elasticsearch ETL task

- Learn about the Elasticsearch ETL task in article **[Elasticsearch ETL task](https://docs.ravendb.net/6.2/server/ongoing-tasks/etl/elasticsearch.md)**.
- Learn how to define a connection string for the Elasticsearch ETL task in section **[Add an Elasticsearch connection string](https://docs.ravendb.net/6.2/client-api/operations/maintenance/connection-strings/add-connection-string.md#add-an-elasticsearch-connection-string)**.
- To manage the Elasticsearch ETL task from the Studio, see **[Studio: Elasticsearch ETL task](https://docs.ravendb.net/6.2/studio/database/tasks/ongoing-tasks/elasticsearch-etl-task.md)**.
  The following example adds an Elasticsearch ETL task:

```csharp
// Define the Elasticsearch ETL task configuration object
// ======================================================
var elasticsearchEtlConfig = new ElasticSearchEtlConfiguration
{
  Name = "task-name",
  ConnectionStringName = "elasticsearch-connection-string-name",
  ElasticIndexes =
  {
      // Define Elasticsearch Indexes
      new ElasticSearchIndex
      {
          // Elasticsearch Index name
          IndexName = "orders",
          // The Elasticsearch document property that will contain the source RavenDB document id.
          // Make sure this property is also defined inside the transform script.
          DocumentIdProperty = "DocId",
          InsertOnlyMode = false
      },
      new ElasticSearchIndex
      {
          IndexName = "lines",
          DocumentIdProperty = "OrderLinesCount",
          // If true, don't send _delete_by_query before appending docs
          InsertOnlyMode = true
      }
  },
  Transforms =
  {
      new Transformation()
      {
          Collections = { "Orders" },
          Script = @"var orderData = {
                     DocId: id(this),
                     OrderLinesCount: this.Lines.length,
                     TotalCost: 0
                     };

                     // Write the `orderData` as a document to the Elasticsearch 'orders' index
                     loadToOrders(orderData);",

          Name = "script-name"
      }
  }
};

// Define the AddEtlOperation
// ==========================
var operation = new AddEtlOperation<ElasticSearchConnectionString>(elasticsearchEtlConfig);

// Execute the operation by passing it to Maintenance.Send
// =======================================================
store.Maintenance.Send(operation);
```

## Add Kafka ETL task

- Learn about the Kafka ETL task in article **[Kafka ETL task](https://docs.ravendb.net/6.2/server/ongoing-tasks/etl/queue-etl/kafka.md)**.
- Learn how to define a connection string for the Kafka ETL task in section **[Add a Kafka connection string](https://docs.ravendb.net/6.2/server/ongoing-tasks/etl/queue-etl/kafka.md#add-a-kafka-connection-string)**.
- To manage the Kafka ETL task from the Studio, see **[Studio: Kafka ETL task](https://docs.ravendb.net/6.2/studio/database/tasks/ongoing-tasks/kafka-etl-task.md)**.
- Examples showing how to add a Kafka ETL task are available in section **[Add a Kafka ETL task](https://docs.ravendb.net/6.2/server/ongoing-tasks/etl/queue-etl/kafka.md#add-a-kafka-etl-task)**.

## Add RabbitMQ ETL task

- Learn about the RabbitMQ ETL task in article **[RabbitMQ ETL task](https://docs.ravendb.net/6.2/server/ongoing-tasks/etl/queue-etl/rabbit-mq.md)**.
- Learn how to define a connection string for the RabbitMQ ETL task in section **[Add a RabbitMQ connection string](https://docs.ravendb.net/6.2/server/ongoing-tasks/etl/queue-etl/rabbit-mq.md#add-a-rabbitmq-connection-string)**.
- To manage the RabbitMQ ETL task from the Studio, see **[Studio: RabbitMQ ETL task](https://docs.ravendb.net/6.2/studio/database/tasks/ongoing-tasks/rabbitmq-etl-task.md)**.
- Examples showing how to add a RabbitMQ ETL task are available in section **[Add a RabbitMQ ETL task](https://docs.ravendb.net/6.2/server/ongoing-tasks/etl/queue-etl/rabbit-mq.md#add-a-rabbitmq-etl-task)**.

## Add Azure Queue Storage ETL task

- Learn about the Azure Queue Storage ETL task in article **[Azure Queue Storage ETL task](https://docs.ravendb.net/6.2/server/ongoing-tasks/etl/queue-etl/azure-queue.md)**.
- Learn how to define a connection string for the Azure Queue Storage ETL task in section  
  **[Add an Azure Queue Storage connection string](https://docs.ravendb.net/6.2/server/ongoing-tasks/etl/queue-etl/azure-queue.md#add-an-azure-queue-storage-connection-string)**.
- To manage the Azure Queue Storage ETL task from the Studio, see **[Studio: Azure Queue Storage ETL task](https://docs.ravendb.net/6.2/studio/database/tasks/ongoing-tasks/azure-queue-storage-etl.md)**.
- Examples showing how to add an Azure Queue Storage ETL task are available in section **[Add a Azure Queue Storage ETL task](https://docs.ravendb.net/6.2/server/ongoing-tasks/etl/queue-etl/azure-queue.md#add-an-azure-queue-storage-etl-task)**.

## Syntax

```csharp
public AddEtlOperation(EtlConfiguration<T> configuration)
```

| Parameter | Type | Description |
| - | - | - |
| **configuration** | `EtlConfiguration<T>` | The ETL configuration object where `T` is the connection string type |

## See also

- [ETL basics](https://docs.ravendb.net/6.2/server/ongoing-tasks/etl/basics.md)
- [RavenDB ETL](https://docs.ravendb.net/6.2/server/ongoing-tasks/etl/raven.md)
- [SQL ETL](https://docs.ravendb.net/6.2/server/ongoing-tasks/etl/sql.md)
- [OLAP ETL](https://docs.ravendb.net/6.2/server/ongoing-tasks/etl/olap.md)
- [Elasticsearch ETL](https://docs.ravendb.net/6.2/server/ongoing-tasks/etl/elasticsearch.md)
- [Kafka ETL](https://docs.ravendb.net/6.2/server/ongoing-tasks/etl/queue-etl/kafka.md)
- [RabbitMQ ETL](https://docs.ravendb.net/6.2/server/ongoing-tasks/etl/queue-etl/rabbit-mq.md)
- [Azure Queue Storage ETL](https://docs.ravendb.net/6.2/server/ongoing-tasks/etl/queue-etl/azure-queue.md)
- [Ongoing tasks - overview](https://docs.ravendb.net/6.2/studio/database/tasks/ongoing-tasks/general-info.md)
- [RavenDB ETL Task](https://docs.ravendb.net/6.2/studio/database/tasks/ongoing-tasks/ravendb-etl-task.md)
- [OLAP ETL Task](https://docs.ravendb.net/6.2/studio/database/tasks/ongoing-tasks/olap-etl-task.md)
- [Elasticsearch ETL Task](https://docs.ravendb.net/6.2/studio/database/tasks/ongoing-tasks/elasticsearch-etl-task.md)
- [Kafka ETL Task](https://docs.ravendb.net/6.2/studio/database/tasks/ongoing-tasks/kafka-etl-task.md)
- [RabbitMQ ETL Task](https://docs.ravendb.net/6.2/studio/database/tasks/ongoing-tasks/rabbitmq-etl-task.md)
- [Azure Queue Storage ETL Task](https://docs.ravendb.net/6.2/studio/database/tasks/ongoing-tasks/azure-queue-storage-etl.md)
- [Add](https://docs.ravendb.net/6.2/client-api/operations/maintenance/connection-strings/add-connection-string.md)
- [Get](https://docs.ravendb.net/6.2/client-api/operations/maintenance/connection-strings/get-connection-string.md)
- [Remove](https://docs.ravendb.net/6.2/client-api/operations/maintenance/connection-strings/remove-connection-string.md)
