如何使用nodejs sdk更改azure cosmos db容器的吞吐量?

时间:2019-05-02 10:39:43

标签: javascript node.js azure azure-cosmosdb

如何使用nodejs(javascript SDK)更新现有容器的吞吐量?

推荐人: 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-

请检查以下REST API请求:

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="  
} '

错误响应:输入授权令牌无法满足请求。请检查是否根据协议构建了预期的有效负载,并检查所使用的密钥。

1 个答案:

答案 0 :(得分:0)

您可以通过如下传递选项来修改它

/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 {

            }
        });