Skip to main content

database_accounts

Creates, updates, deletes, gets or lists a database_accounts resource.

Overview

Namedatabase_accounts
TypeResource
Idazure.cosmosdb.database_accounts

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
nameobjectThe name information for the metric.
endTimestring (date-time)The end time for the metric (ISO-8601 format).
metricValuesarrayThe metric values for the specified time window and timestep.
startTimestring (date-time)The start time for the metric (ISO-8601 format).
timeGrainstringThe time grain to be used to summarize the metric values.
unitstringThe unit of the metric. Known values are: "Count", "Bytes", "Seconds", "Percent", "CountPerSecond", "BytesPerSecond", and "Milliseconds". (Count, Bytes, Seconds, Percent, CountPerSecond, BytesPerSecond, Milliseconds)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
list_metricsselectresource_group_name, account_name, subscription_id, $filterRetrieves the metrics determined by the given filter for the given database account.
getselectresource_group_name, account_name, subscription_idRetrieves the properties of an existing Azure Cosmos DB database account.
list_by_resource_groupselectresource_group_name, subscription_idLists all the Azure Cosmos DB database accounts available under the given resource group.
listselectsubscription_idLists all the Azure Cosmos DB database accounts available under the subscription.
create_or_updateinsertresource_group_name, account_name, subscription_id, propertiesCreates or updates an Azure Cosmos DB database account. The "Update" method is preferred when performing updates on an account.
updateupdateresource_group_name, account_name, subscription_idUpdates the properties of an existing Azure Cosmos DB database account.
create_or_updatereplaceresource_group_name, account_name, subscription_id, propertiesCreates or updates an Azure Cosmos DB database account. The "Update" method is preferred when performing updates on an account.
deletedeleteresource_group_name, account_name, subscription_idDeletes an existing Azure Cosmos DB database account.
list_keysexecresource_group_name, account_name, subscription_idLists the access keys for the specified Azure Cosmos DB database account.
list_connection_stringsexecresource_group_name, account_name, subscription_idLists the connection strings for the specified Azure Cosmos DB database account.
list_read_only_keysexecresource_group_name, account_name, subscription_idLists the read-only access keys for the specified Azure Cosmos DB database account.
get_read_only_keysexecresource_group_name, account_name, subscription_idLists the read-only access keys for the specified Azure Cosmos DB database account.
list_usagesexecresource_group_name, account_name, subscription_id$filterRetrieves the usages (most recent data) for the given database account.
list_metric_definitionsexecresource_group_name, account_name, subscription_idRetrieves metric definitions for the given database account.
failover_priority_changeexecresource_group_name, account_name, subscription_id, failoverPoliciesChanges the failover priority for the Azure Cosmos DB database account. A failover priority of 0 indicates a write region. The maximum value for a failover priority = (total number of regions - 1). Failover priority values must be unique for each of the regions in which the database account exists.
offline_regionexecresource_group_name, account_name, subscription_id, regionOffline the specified region for the specified Azure Cosmos DB database account.
online_regionexecresource_group_name, account_name, subscription_id, regionOnline the specified region for the specified Azure Cosmos DB database account.
regenerate_keyexecresource_group_name, account_name, subscription_id, keyKindRegenerates an access key for the specified Azure Cosmos DB database account.
check_name_existsexecaccount_nameChecks that the Azure Cosmos DB account name already exists. A valid account name may contain only lowercase letters, numbers, and the '-' character, and must be between 3 and 50 characters.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
$filterstringAn OData filter expression that describes a subset of metrics to return. The parameters that can be filtered are name.value (name of the metric, can have an or of multiple names), startTime, endTime, and timeGrain. The supported operator is eq. Required.
account_namestringCosmos DB database account name. Required.
resource_group_namestringThe name of the resource group. The name is case insensitive. Required.
subscription_idstring
$filterstringAn OData filter expression that describes a subset of usages to return. The supported parameter is name.value (name of the metric, can have an or of multiple names). Default value is None.

SELECT examples

Retrieves the metrics determined by the given filter for the given database account.

SELECT
name,
endTime,
metricValues,
startTime,
timeGrain,
unit
FROM azure.cosmosdb.database_accounts
WHERE resource_group_name = '{{ resource_group_name }}' -- required
AND account_name = '{{ account_name }}' -- required
AND subscription_id = '{{ subscription_id }}' -- required
AND $filter = '{{ $filter }}' -- required
;

INSERT examples

Creates or updates an Azure Cosmos DB database account. The "Update" method is preferred when performing updates on an account.

INSERT INTO azure.cosmosdb.database_accounts (
location,
tags,
identity,
kind,
properties,
resource_group_name,
account_name,
subscription_id
)
SELECT
'{{ location }}',
'{{ tags }}',
'{{ identity }}',
'{{ kind }}',
'{{ properties }}' /* required */,
'{{ resource_group_name }}',
'{{ account_name }}',
'{{ subscription_id }}'
RETURNING
id,
name,
identity,
kind,
location,
properties,
systemData,
tags,
type
;

UPDATE examples

Updates the properties of an existing Azure Cosmos DB database account.

UPDATE azure.cosmosdb.database_accounts
SET
tags = '{{ tags }}',
location = '{{ location }}',
identity = '{{ identity }}',
properties = '{{ properties }}'
WHERE
resource_group_name = '{{ resource_group_name }}' --required
AND account_name = '{{ account_name }}' --required
AND subscription_id = '{{ subscription_id }}' --required
RETURNING
id,
name,
identity,
kind,
location,
properties,
systemData,
tags,
type;

REPLACE examples

Creates or updates an Azure Cosmos DB database account. The "Update" method is preferred when performing updates on an account.

REPLACE azure.cosmosdb.database_accounts
SET
location = '{{ location }}',
tags = '{{ tags }}',
identity = '{{ identity }}',
kind = '{{ kind }}',
properties = '{{ properties }}'
WHERE
resource_group_name = '{{ resource_group_name }}' --required
AND account_name = '{{ account_name }}' --required
AND subscription_id = '{{ subscription_id }}' --required
AND properties = '{{ properties }}' --required
RETURNING
id,
name,
identity,
kind,
location,
properties,
systemData,
tags,
type;

DELETE examples

Deletes an existing Azure Cosmos DB database account.

DELETE FROM azure.cosmosdb.database_accounts
WHERE resource_group_name = '{{ resource_group_name }}' --required
AND account_name = '{{ account_name }}' --required
AND subscription_id = '{{ subscription_id }}' --required
;

Lifecycle Methods

Lists the access keys for the specified Azure Cosmos DB database account.

EXEC azure.cosmosdb.database_accounts.list_keys 
@resource_group_name='{{ resource_group_name }}' --required,
@account_name='{{ account_name }}' --required,
@subscription_id='{{ subscription_id }}' --required
;