Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with change feeds #5391

Closed
emiln opened this issue Oct 4, 2019 · 3 comments
Closed

Problem with change feeds #5391

emiln opened this issue Oct 4, 2019 · 3 comments
Assignees
Labels
Client This issue points to a problem in the data-plane of the library. Cosmos customer-reported Issues that are reported by GitHub users external to the Azure organization.

Comments

@emiln
Copy link

emiln commented Oct 4, 2019

I'm trying to read the change feed of a Cosmos DB document collection using @azure/cosmos. In particular I'm running the following code right now:

const { CosmosClient } = require('@azure/cosmos');

const endpoint = 'https://<some-host>.documents.azure.com';
const key = '<some-key>';
const client = new CosmosClient({ endpoint, key });

const databaseDefinition = { 'id': '<some-db>' };
const collectionDefinition = { 'id': '<some-coll>' };

async function read() {
  const { database } = await client.databases.createIfNotExists(databaseDefinition);
  console.log('Database exists now');

  const { container } = await database.containers.createIfNotExists(collectionDefinition);
  console.log('Collection exists now');

  const options = {};
  const changeFeed = container.items.readChangeFeed('/id', options);
  console.log('Change feed created');

  while (changeFeed.hasMoreResults) {
    const { result } = await changeFeed.fetchNext();
    console.log(result);
  }
}

read().catch(console.error);

I expected it to iterate through the change feed, but instead I'm getting the following error:

{ Error: Sql api is not supported for this database account
ActivityId: bd845770-d3cd-42b6-b00c-7d13da40fac9, Microsoft.Azure.Documents.Common/2.5.1
    at <workdir>/node_modules/@azure/cosmos/dist/index.js:6971:39
    at Generator.next (<anonymous>)
    at fulfilled (<workdir>/node_modules/tslib/tslib.js:107:62)
    at process._tickCallback (internal/process/next_tick.js:68:7)
  code: 403,
  body:
   { code: 'Forbidden',
     message:
      'Sql api is not supported for this database account\r\nActivityId: bd845770-d3cd-42b6-b00c-7d13da40fac9, Microsoft.Azure.Documents.Common/2.5.1' },
  headers:
   { 'content-location':
      'https://<some-host>-<some-zone>.documents.azure.com/dbs/<some-db>/colls/<some-coll>/docs',
     'content-type': 'application/json',
     date: 'Fri, 04 Oct 2019 11:08:09 GMT',
     server: 'Microsoft-HTTPAPI/2.0',
     'strict-transport-security': 'max-age=31536000',
     'transfer-encoding': 'chunked',
     'x-ms-activity-id': 'bd845770-d3cd-42b6-b00c-7d13da40fac9',
     'x-ms-gatewayversion': 'version=2.5.1',
     'x-ms-throttle-retry-count': 0,
     'x-ms-throttle-retry-wait-time-ms': 0 },
  activityId: 'bd845770-d3cd-42b6-b00c-7d13da40fac9' }

What am I doing wrong, and what does it mean that my database account does not support SQL API? Am I even using any SQL API?

I hope you can help me out.

@loarabia loarabia added Client This issue points to a problem in the data-plane of the library. Cosmos customer-reported Issues that are reported by GitHub users external to the Azure organization. labels Oct 4, 2019
@southpolesteve
Copy link
Contributor

@emiln When cosmos accounts are created, you pick the type of API you want to use. SQL is the default, but we also support Mongo, Cassandra, Gremlin, and Tables. Currently, accounts can only be used via a single API. @azure/cosmos is designed specifically for the SQL API and won't work with the others which is why you are seeing the error. Can you email me your account name? [email protected] I can verify which account type you have.

@emiln
Copy link
Author

emiln commented Oct 7, 2019

Hi, Steve

Thanks a lot for the answer. I suspect you're probably right about the type. I've written you on the email address you mentioned.

@ghost
Copy link

ghost commented Oct 7, 2019

Thanks for working with Microsoft on GitHub! Tell us how you feel about your experience using the reactions on this comment.

@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Client This issue points to a problem in the data-plane of the library. Cosmos customer-reported Issues that are reported by GitHub users external to the Azure organization.
Projects
None yet
Development

No branches or pull requests

3 participants