Azure Cosmos MongoDB says Out of Throughput of one account, but is working on a different account

92 Views Asked by At

When I implemented my codes on my local end and my private account, Azure cosmos DB works for me. But when I try to connect to a different account, I got this warning: Error in /nonogram route: MongoError: Error=2, Details='Response status code does not indicate success: BadRequest (400); Substatus: 1028; ActivityId: eb8ca7c6-fecf-41b7-9376-d69abad0772b; Reason: (Message: {"Errors":["Your account is currently configured with a total throughput limit of 1000 RU/s. This operation failed because it would have increased the total throughput to 1200 RU/s. See https://aka.ms/cosmos-tp-limit for more information."]}

and I really do not understand why.

here is my mongo.js code:

const { MongoClient } = require('mongodb');
const env = require('./env/environment');

const client = new MongoClient(env.cosmosDbConnectionString,{
    useNewUrlParser: true,
    useUnifiedTopology: true,
});

let db;

const connectDB = async () => {
    try {
        await client.connect();
        console.log('Connected to Cosmos DB');
        db = client.db('test'); // Specify the database name
    } catch (err) {
        console.error('Failed to connect to MongoDB', err);
        process.exit(1);
    }
};

const getDb = () => {
    if (!db) {
        throw new Error("Database not initialized");
    }
    return db;
};

module.exports = { connectDB, getDb };
0

There are 0 best solutions below