Allow connection string users to add database to their Mongo serverless account (#1924)
* Allow connection string users to create databases mongo ser * Allow connection string users to create databases for the mongo serverless accounts * Allow connection string users to create databases for the mongo serverless accounts --------- Co-authored-by: Asier Isayas <aisayas@microsoft.com>
This commit is contained in:
parent
2ef036ee94
commit
3d1f280378
|
@ -4,6 +4,7 @@ import * as DataModels from "../../Contracts/DataModels";
|
||||||
import { useDatabases } from "../../Explorer/useDatabases";
|
import { useDatabases } from "../../Explorer/useDatabases";
|
||||||
import { userContext } from "../../UserContext";
|
import { userContext } from "../../UserContext";
|
||||||
import { getDatabaseName } from "../../Utils/APITypeUtils";
|
import { getDatabaseName } from "../../Utils/APITypeUtils";
|
||||||
|
import { logConsoleInfo, logConsoleProgress } from "../../Utils/NotificationConsoleUtils";
|
||||||
import { createUpdateCassandraKeyspace } from "../../Utils/arm/generatedClients/cosmos/cassandraResources";
|
import { createUpdateCassandraKeyspace } from "../../Utils/arm/generatedClients/cosmos/cassandraResources";
|
||||||
import { createUpdateGremlinDatabase } from "../../Utils/arm/generatedClients/cosmos/gremlinResources";
|
import { createUpdateGremlinDatabase } from "../../Utils/arm/generatedClients/cosmos/gremlinResources";
|
||||||
import { createUpdateMongoDBDatabase } from "../../Utils/arm/generatedClients/cosmos/mongoDBResources";
|
import { createUpdateMongoDBDatabase } from "../../Utils/arm/generatedClients/cosmos/mongoDBResources";
|
||||||
|
@ -15,7 +16,6 @@ import {
|
||||||
MongoDBDatabaseCreateUpdateParameters,
|
MongoDBDatabaseCreateUpdateParameters,
|
||||||
SqlDatabaseCreateUpdateParameters,
|
SqlDatabaseCreateUpdateParameters,
|
||||||
} from "../../Utils/arm/generatedClients/cosmos/types";
|
} from "../../Utils/arm/generatedClients/cosmos/types";
|
||||||
import { logConsoleInfo, logConsoleProgress } from "../../Utils/NotificationConsoleUtils";
|
|
||||||
import { client } from "../CosmosClient";
|
import { client } from "../CosmosClient";
|
||||||
import { handleError } from "../ErrorHandlingUtils";
|
import { handleError } from "../ErrorHandlingUtils";
|
||||||
|
|
||||||
|
@ -152,8 +152,18 @@ async function createDatabaseWithSDK(params: DataModels.CreateDatabaseParams): P
|
||||||
createBody.throughput = params.offerThroughput;
|
createBody.throughput = params.offerThroughput;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
let response: DatabaseResponse;
|
||||||
const response: DatabaseResponse = await client().databases.create(createBody);
|
try {
|
||||||
|
response = await client().databases.create(createBody);
|
||||||
|
} catch (error) {
|
||||||
|
if (error.message.includes("Shared throughput database creation is not supported for serverless accounts")) {
|
||||||
|
createBody.maxThroughput = undefined;
|
||||||
|
createBody.throughput = undefined;
|
||||||
|
response = await client().databases.create(createBody);
|
||||||
|
} else {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
return response.resource;
|
return response.resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue