如何在 JS 中获取 CosmosDB 中的帐户名
how to get account name in CosmosDB in JS
我想获取cosmos DB的账户名
不过这里好像只有账户端点。
const {CosmosClient} = require("@azure/cosmos");
const CONNECTION_STRING = process.env["CosmosDBConnectionString"];
const DATABASE_ID = process.env["CosmosDBDatabaseId"];
const client = new CosmosClient(CONNECTION_STRING);
const resource = (await client.getDatabaseAccount()).resource;
resource.readableLocations[0].databaseAccountEndpoint
//'https://xxxxxx-japaneast.documents.azure.com:443/'
既然有了端点,难道不能像下面这样用JS方法获取账号名吗?
const str = resource.readableLocations[0].databaseAccountEndpoint;
console.log(str.split('://').pop().split('.documents')[0]);
我想获取cosmos DB的账户名
不过这里好像只有账户端点。
const {CosmosClient} = require("@azure/cosmos");
const CONNECTION_STRING = process.env["CosmosDBConnectionString"];
const DATABASE_ID = process.env["CosmosDBDatabaseId"];
const client = new CosmosClient(CONNECTION_STRING);
const resource = (await client.getDatabaseAccount()).resource;
resource.readableLocations[0].databaseAccountEndpoint
//'https://xxxxxx-japaneast.documents.azure.com:443/'
既然有了端点,难道不能像下面这样用JS方法获取账号名吗?
const str = resource.readableLocations[0].databaseAccountEndpoint;
console.log(str.split('://').pop().split('.documents')[0]);