# tCosmosDBSQLAPIOutput

Inserts, updates, upserts, or deletes documents in a Cosmos database collection based on the incoming flow from the preceding component through SQL API.

## tCosmosDBSQLAPIOutput Standard properties

These properties are used to configure tCosmosDBSQLAPIOutput running in the Standard Job framework.

The Standard tCosmosDBSQLAPIOutput component belongs to the Databases NoSQL family.

The component in this framework is available in all Talend products.

## Basic settings

| Properties | Description |
| --- | --- |
| Property type | Either Built-in or Repository.<br><br><ul> <li> <span>Built-in</span>: No property data is stored                      centrally.</li> <li> <span>Repository</span>: Select the repository file                        in which the properties are stored. The fields that follow are completed                        automatically using the data retrieved.</li> </ul> |
| Edit Schema | Click Edit<br>schema to make changes to the schema. If the current schema is of the Repository type, three options are available:<br><br><ul> <li> <p> <span>View schema</span>: choose this                option to view the schema only.</p> </li> <li> <p> <span>Change to built-in property</span>:                choose this option to change the schema to <span>Built-in</span> for local changes.</p> </li> <li> <p> <span>Update repository connection</span>:                choose this option to change the schema stored in the repository and decide whether                to propagate the changes to all the Jobs upon completion.</p> <p>If you just want to                propagate the changes to the current Job, you can select <span>No</span> upon completion and choose this schema metadata                again in the <span>Repository Content</span>                window.</p> </li> </ul><br><br>This component supports dynamic schema when inserting documents to a<br>collection. To use the dynamic schema feature, make sure the collection does<br>not have any partition keys, and the schema contains only one column, with the<br>DB column set to \* and<br>Type set to String (if the<br>input type is String) or Object (if<br>the input type is Object).<br><br>Information noteNote:<br><br><ul> <li>The dynamic schema feature is available only when                              <kbd>Insert</kbd> is selected from the <span>Action                              on data</span> drop-down list.</li> <li>The dynamic schema feature is available only when you have installed the                           8.0.1-R2024-04 <span>Talend Studio</span> Monthly update or a later one delivered by <span>Talend</span>. For more information, check with your administrator.</li> </ul> |
| URI | Enter the URI of your Cosmos user account. As the field prompts, the URI of a<br>Cosmos DB user account is in the format of https://{your\_account}.document.azure.com:443. You can obtain the URI<br>on the Keys pane of Azure portal. Click [Create an Azure Cosmos DB account](https://docs.microsoft.com/en-us/azure/cosmos-db/create-cosmosdb-resources-portal) for<br>related information. |
| Primary key | Enter the primary key of your CosmosDB user account. You can obtain the primary<br>key on the Keys pane of Azure portal.<br>Click [Create an Azure Cosmos DB account](https://docs.microsoft.com/en-us/azure/cosmos-db/create-cosmosdb-resources-portal) for related<br>information.<br><br>To enter the primary key, click the [...] button<br>next to the Primary key field to bring out the Enter a new<br>password dialog box, enter the primary key in the text field, and click<br>OK. Note that you can enter the primary key either in a JSON string<br>in the pure password mode or as a Java expression in the Java<br>mode. You can toggle between the two modes by clicking switch to<br>Java mode or switch to pure password mode on the top<br>of the text field.<br><br>Information noteNote:<br><br><ul> <li>The two password modes are available only when you have installed the                  8.0.1-R2022-05 <span>Talend Studio</span>                  monthly update or a later one delivered by <span>Talend</span>. For more information, check with your administrator.</li> <li>If the 8.0.1-R2022-05 <span>Talend Studio</span>                  monthly update or a later one delivered by <span>Talend</span>                  is not installed, you can enter primary keys in the <span>Java mode</span>                  only. </li> </ul> |
| Database ID | Enter the database name. |
| Collection ID | Enter the collection name. |
| Create collection if not exist | Select this option to have the collection specified in the Collection ID<br>field created if it does not exist. This option is not available if<br>Update or Delete is selected from the<br>Data action drop-down list. |
| Data action | Select one of the following options.<br><br><ul> <li> <p> <span>Insert</span>: inserts documents.</p> </li> <li> <p> <span>Update</span>: replaces the existing documents with the              incoming data but keeps the technical ID of these documents.</p> </li> <li> <p> <span>Upsert</span>: inserts a document if it does not exist              otherwise it applies the same rules as <span>Update</span>.</p> </li> <li> <p> <span>Delete</span>: deletes documents.</p> </li> </ul> |
| Availability-note[Deprecated](https://help.talend.com/r/en-US/Cloud/labels-on-talend-help-center/availability-deprecated)<br><br>This content is deprecated.<br><br>Auto ID generation | Select this option to generate IDs for the documents processed.<br><br>Information noteDeprecation: This<br>option is deprecated since the 8.0.1-R2024-03 monthly release. |

## Advanced settings

| Properties | Description |
| --- | --- |
| tStatCatcher Statistics | Select this check box to collect the log data at the component<br>level. |
| Connection mode | Specify the connection mode to be used. Two options are available: Gateway and DirectHttps. Click [ConnectionMode](https://docs.microsoft.com/en-us/java/api/com.microsoft.azure.cosmosdb.connectionmode?view=azure-java-legacy) for related information. |
| Max connection pool size | Set the maximum connection pool size. The default is 1000. |
| Consistency level | Set the consistency level. Click [Consistency levels](https://docs.microsoft.com/en-us/azure/cosmos-db/consistency-levels) for related<br>information. |
| Partition key | Enter the key of the partition whose documents will be removed. The partition<br>key is recommended to be a non-null value.<br><br>With the 8.0.1-R2024-03 monthly release, you can enter three different types of<br>partition keys: Boolean, Double, and String. The partition keys can also be<br>configured up to a three level hierarchy. For more information, see [Hierarchical partition keys in Azure Cosmos<br>DB](https://learn.microsoft.com/en-us/azure/cosmos-db/hierarchical-partition-keys?tabs=java-v4%2Cbicep) from the Microsoft documentation.<br><br>This option is available when you select the Create collection if<br>not exsist check box. |

## Global Variables

| Variables | Description |
| --- | --- |
| ERROR\_MESSAGE | The error message generated by the component when an error<br>occurs. This is an After variable and it returns a string. |
| NB\_LINE | The number of rows processed. This is an After variable and<br>it returns an integer. |

## Usage

| Usage guidance | Description |
| --- | --- |
| **Usage rule** | tCosmosDBSQLAPIOutput executes the action defined on<br>the collection in the database based on the flow incoming from the preceding<br>component in the Job. |
| **Cosmos DB limitation for HTTPS proxies with authentication** | HTTP proxies and HTTPS proxies work with the tSetProxy<br>component, however:<br><br><ul> <li>HTTPS proxies with authentication do not work with the <span>Use                              authorization</span> option in <span>tSetProxy</span>                           for this component. This is because the Cosmos DB SDK does not use Java’s                              <span>Authenticator</span> for HTTPS proxy tunneling and instead                           relies on JVM system properties.</li> <li>For this component to work with an authenticated HTTPS proxy, you must                           manually configure proxy credentials as JVM arguments in <span><span>Run</span><abbr> &gt; </abbr><span>Advanced Settings</span><abbr> &gt; </abbr><span>JVM arguments</span></span>: <pre><code><pre><code><code>-Dhttps.proxyUser=&lt;username&gt;-Dhttps.proxyPassword=&lt;password&gt;</code></code></pre></code></pre></li> </ul><br><br>Additional limitation: Proxy configuration is managed through global JVM system<br>properties, so using multiple, different proxy settings for different<br>components in the same Job is not recommended, as the configuration will not<br>work as intended. |