0
votes

How to update the throughput of the existing container using nodejs (javascript SDK)?

Referrences: https://docs.microsoft.com/en-us/azure/cosmos-db/set-throughput#update-throughput-on-a-database-or-a-container

https://docs.microsoft.com/en-us/javascript/api/%40azure/cosmos/container?view=azure-node-latest#replace-containerdefinition--requestoptions-

Please check the below REST API request:

curl -X PUT \
  https://mydbinstance.documents.azure.com/offers/pSMeVMS0g3fc= \
  -H 'Accept: */*' \
  -H 'Cache-Control: no-cache' \
  -H 'Connection: keep-alive' \
  -H 'Content-Type: application/json' \
  -H 'Host: mydbinstance.documents.azure.com' \
  -H 'authorization: type=master&ver=1.0&sig=XE8P49N9Y9yhny09yYJY690N9th9JOIHYnh9N8N89NTHn*TjH=' \
  -H 'content-length: 266' \
  -H 'x-ms-date: Fri, 03 May 2019 10:05:06 GMT' \
  -H 'x-ms-version: 2016-07-11' \
  -d '{  
  "id": "pSMeVMS0g3fc=",  
  "_rid": "pSMeVMS0g3fc=",  
  "_self": "offers/pSMeVMS0g3fc=/",  
  "offerVersion": "V2",  
  "resource": "dbs/pNZpAA==/colls/pSMeVMS0g3fc=/",  
  "content": {  
    "offerThroughput": 4000 
   }, 
  "offerResourceId": "pSMeVMS0g3fc="  
} '

Error Response: The input authorization token can't serve the request. Please check that the expected payload is built as per the protocol, and check the key being used.

1

1 Answers

0
votes

You could modify it by passing the options as follows

/The following code will create a collection in the database. This is where the documents will be stored.
        client.createCollection(databaseUrl, cosmosDb.collection, { offerThroughput: 400 }, (err, created) => {
            if (err) {
                console.log(err);
            }
            else {

            }
        });