CosmosDB Managing Resources: Account Creation
Syntax
{
"id": "string",
"location": "string",
"tags": {},
"properties": {
"consistencyPolicy": {
"defaultConsistencyLevel": "string",
"maxStalenessPrefix": "integer",
"maxStalenessIntervalInSeconds ": "integer",
"custom": {
"name": "string",
"properties": {}
}
},
"enableAutomaticFailover": false,
"ipRangeFilter": "string",
"isVirtualNetworkFilterEnabled": false,
"virtualNetworkRules": [
{
"id": "string",
"ignoreMissingVnetServiceEndpoint": false
}
],
"publicNetworkAccess": "string"
}
}
Example
{
"id": "myCosmosDBAccount",
"location": "eastus2",
"tags": {
"environment": "prod"
},
"properties": {
"consistencyPolicy": {
"defaultConsistencyLevel": "Session"
},
"enableAutomaticFailover": true,
"publicNetworkAccess": "Enabled"
}
}
Output
Upon successful execution, the output will be a JSON object containing the newly created CosmosDB account's metadata.
Explanation
The above syntax creates a CosmosDB account with the specified ID, location, tags and properties. In the properties
field, the consistencyPolicy
object can be configured for custom consistency levels. enableAutomaticFailover
enables automatic failover in case of a disaster. ipRangeFilter
restricts access to the account from a specific set of IP addresses. publicNetworkAccess
specifies whether the account is accessible over the public internet or not.
Use
This syntax can be used to create a new CosmosDB account in Azure. This is a foundational step for creating and managing resources within the account.
Important Points
- Account names must be unique within Azure
- Choosing a location close to your users can improve performance
- Consistency policies can be modified after creation, but cause downtime during the change
Summary
Creating a CosmosDB account is a crucial first step in managing and creating database resources within the account. The cosmos.azure.com
portal and Azure CLI both enable easy creation of a new account. Account parameters such as location, consistency level, and network access can be customized to suit application needs.