Jochem
Jochem

Reputation: 13

Setting RequestOptions CosmosDB Output binding on azure functions

Currently I am using an azure function to store data into a cosmosDB.

I am trying to implement this using an output binding

[CosmosDB(databaseName: "ToDoItems", collectionName: "Items", ConnectionStringSetting = "CosmosDBConnection")]out dynamic document.

Is there a way I can set RequestOptions in the output binding above like you can when using the azure cosmosdb sdk as follow?

Document doc = await client.UpsertDocumentAsync(
        "something",
        {},
        new RequestOptions
        {
           AccessCondition = new AccessCondition {
             Condition = document.ETag,
             Type = AccessConditionType.IfMatch
           }
        }); ```

Upvotes: 1

Views: 481

Answers (1)

Matias Quaranta
Matias Quaranta

Reputation: 15603

Yes. You can obtain the DocumentClient instance underneath and run the UpsertDocumentAsync yourself:

[CosmosDB(databaseName: "ToDoItems", 
    collectionName: "Items", 
    ConnectionStringSetting = "CosmosDBConnection")] DocumentClient client

Has the same beneficial effect, as the instance you get injected is the same that the binding maintains underneath across executions.

Upvotes: 2

Related Questions