Create a database (C#)
Creates a database.
To replicate a database to additional datacenters, see Deploy an Astra DB Serverless database to multiple regions.
|
You need an application token with permission to create and configure databases, such as the Organization Administrator role. For more information, see Get endpoint and token. |
Result
Creates a database and returns a DatabaseAdminAstra object that can perform administrative actions on the newly-created database.
Parameters
Use the CreateDatabaseAsync method, which belongs to the AstraDatabasesAdmin class.
You can also use CreateDatabase, which is the synchronous version of the method.
Method signature
public Task<DatabaseAdminAstra> CreateDatabaseAsync(
CreateDatabaseOptions options
);
| Name | Type | Summary |
|---|---|---|
|
Optional.
Options for this operation.
For more information and examples for general options such as timeout, see Customize API interaction.
See Method-specific properties of the |
| Name | Type | Summary | ||
|---|---|---|---|---|
|
|
The name of the database. Database names must follow these rules:
|
||
|
|
The cloud provider that should host the database.
Can be one of: |
||
|
|
The cloud provider region in which to create the database. The available regions depend on your subscription plan and the database type. To find available regions, see Find available regions (C#). |
||
|
|
Optional. The name for the database’s initial keyspace. Default: default_keyspace |
||
|
|
Optional. The ID of the PCU group to use for provisioning the database. The specified PCU group must have the same cloud provider and region as the database. Only applicable for organizations that use PCU groups. Default: No PCU group |
||
|
|
Optional. Whether the database is a Serverless (vector) database or a Serverless (non-vector) database. To create a Serverless (vector) database, set this parameter to To create a Serverless (non-vector) database, set it to
Default: vector |
||
|
|
Optional. The database tier. If specified, must be Default: serverless |
||
|
|
Optional. The number of capacity units for the database. This is unrelated to PCU group capacity. If specified, must be Default: 1 |
||
|
|
Optional. Whether to wait for the database to become active before returning. If false, the method returns immediately after issuing the creation request, but you cannot work with the database until it becomes active. Default: true |
Examples
The following examples demonstrate how to create a database.
using DataStax.AstraDB.DataApi;
using DataStax.AstraDB.DataApi.Admin;
namespace Examples;
public class Program
{
static async Task Main()
{
var client = new DataAPIClient("APPLICATION_TOKEN");
var admin = client.GetAstraDatabasesAdmin();
var databaseAdmin = await admin.CreateDatabaseAsync(
new CreateDatabaseOptions()
{
Name = "DATABASE_NAME",
CloudProvider = CloudProviderType.AWS,
Region = "us-east-2",
}
);
}
}
Client reference
For more information, see the client reference.