Skip to main content
selectMicrosoft Azurelast verified 2026-07-30
Servicescosmosdb
CredentialsAZURE_TENANT_ID AZURE_CLIENT_ID AZURE_CLIENT_SECRET
PermissionsMicrosoft.DocumentDB/databaseAccounts/read

Azure Cosmos DB table lifecycle

Lists the tables in a Cosmos DB account, and covers provisioning a serverless Table API account and creating and deleting tables in it. This is the control plane: it manages the account and the table containers themselves, addressed through Azure Resource Manager with subscription and resource group scoping.

Query

SELECT name
FROM azure.cosmosdb.table_resources
WHERE subscription_id = '{{subscription_id}}'
AND resource_group_name = '{{resource_group_name}}'
AND account_name = '{{account_name}}';

Provisioning a serverless Table API account

The capabilities array is what selects the API and the billing model - EnableTable for the Table API, EnableServerless for per-request billing:

INSERT INTO azure.cosmosdb.database_accounts(
account_name,
resource_group_name,
subscription_id,
location,
kind,
properties
)
SELECT
'{{account_name}}',
'{{resource_group_name}}',
'{{subscription_id}}',
'westus2',
'GlobalDocumentDB',
'{"databaseAccountOfferType": "Standard", "locations": [{"locationName": "westus2", "failoverPriority": 0}], "capabilities": [{"name": "EnableTable"}, {"name": "EnableServerless"}]}';

Poll until the account is usable:

SELECT name, provisioning_state
FROM azure.cosmosdb.database_accounts
WHERE subscription_id = '{{subscription_id}}'
AND resource_group_name = '{{resource_group_name}}';

Creating a table

INSERT INTO azure.cosmosdb.table_resources(
account_name,
resource_group_name,
subscription_id,
table_name,
properties
)
SELECT
'{{account_name}}',
'{{resource_group_name}}',
'{{subscription_id}}',
'my-table',
'{"resource": {"id": "my-table"}, "options": {}}';

Deleting a table

DELETE FROM azure.cosmosdb.table_resources
WHERE subscription_id = '{{subscription_id}}'
AND resource_group_name = '{{resource_group_name}}'
AND account_name = '{{account_name}}'
AND table_name = 'my-table';

Notes

The table id is given twice on create - once as the table_name parameter that builds the URL and once inside the resource object in the body - and the two must agree. Account provisioning is asynchronous and typically takes a minute or two, so poll provisioning_state rather than creating a table immediately after the insert returns. On a serverless account the keyed single-table read (adding table_name to the list query) fails with BadRequest and the message that reading or replacing offers is not supported for serverless accounts, because that path also reads the throughput offer; list the tables and filter client-side instead. Account names are globally unique and lowercase. Deleting the account or its resource group removes every table with it. Table row operations are a separate data-plane surface reached through azure.data_tables against the account's own endpoint rather than through Resource Manager, and authenticate independently of these control-plane calls.

Related queries