Skip to content

Commit 889fde2

Browse files
Merge pull request #201651 from v-thepet/mjbrown
DevEdit: Four Cosmos DB Azure CLI articles
2 parents d12040c + 22c0855 commit 889fde2

File tree

6 files changed

+156
-104
lines changed

6 files changed

+156
-104
lines changed

articles/cosmos-db/audit-control-plane-logs.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,5 +225,6 @@ AzureDiagnostics
225225

226226
## Next steps
227227

228+
* [Prevent Azure Cosmos DB resources from being deleted or changed](resource-locks.md)
228229
* [Explore Azure Monitor for Azure Cosmos DB](../azure-monitor/insights/cosmosdb-insights-overview.md?toc=/azure/cosmos-db/toc.json&bc=/azure/cosmos-db/breadcrumb/toc.json)
229230
* [Monitor and debug with metrics in Azure Cosmos DB](use-metrics.md)

articles/cosmos-db/resource-locks.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,17 @@ When applying a lock to an Azure Cosmos DB resource, use the following formats:
112112
]
113113
```
114114

115+
## Samples
116+
117+
Manage resource locks for Azure Cosmos DB:
118+
119+
- Cassandra API keyspace and table [Azure CLI](scripts\cli\cassandra\lock.md) | [Azure PowerShell](scripts\powershell\cassandra\lock.md)
120+
- Gremlin API database and graph [Azure CLI](scripts\cli\gremlin\lock.md) | [Azure PowerShell](scripts\powershell\gremlin\lock.md)
121+
- MongoDB API database and collection [Azure CLI](scripts\cli\mongodb\lock.md)| [Azure PowerShell](scripts\powershell\mongodb\lock.md)
122+
- Core (SQL) API database and container [Azure CLI](scripts\cli\sql\lock.md) | [Azure PowerShell](scripts\powershell\sql\lock.md)
123+
- Table API table [Azure CLI](scripts\cli\table\lock.md) | [Azure PowerShell](scripts\powershell\table\lock.md)
124+
115125
## Next steps
116126

117127
- [Overview of Azure Resource Manager Locks](../azure-resource-manager/management/lock-resources.md)
128+
- [How to audit Azure Cosmos DB control plane operations](audit-control-plane-logs.md)
Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,66 @@
11
---
2-
title: Create a Core (SQL) API database and container with autoscale for Azure Cosmos DB
3-
description: Create a Core (SQL) API database and container with autoscale for Azure Cosmos DB
2+
title: Azure Cosmos DB SQL API account, database, and container with autoscale
3+
description: Use Azure CLI to create an Azure Cosmos DB Core (SQL) API account, database, and container with autoscale.
44
author: seesharprun
55
ms.author: sidandrews
66
ms.reviewer: mjbrown
77
ms.service: cosmos-db
88
ms.subservice: cosmosdb-sql
99
ms.topic: sample
10-
ms.date: 02/21/2022
10+
ms.date: 06/22/2022
11+
ms.custom: kr2b-contr-experiment
1112
---
1213

13-
# Create an Azure Cosmos Core (SQL) API account, database and container with autoscale using Azure CLI
14+
# Create an Azure Cosmos DB SQL API account, database, and container with autoscale
1415

1516
[!INCLUDE[appliesto-sql-api](../../../includes/appliesto-sql-api.md)]
1617

17-
The script in this article demonstrates creating a SQL API database and container with autoscale.
18+
The script in this article creates an Azure Cosmos DB Core (SQL) API account, database, and container with autoscale.
1819

19-
[!INCLUDE [quickstarts-free-trial-note](../../../../../includes/quickstarts-free-trial-note.md)]
20+
## Prerequisites
2021

21-
[!INCLUDE [azure-cli-prepare-your-environment.md](../../../../../includes/azure-cli-prepare-your-environment.md)]
22+
- [!INCLUDE [quickstarts-free-trial-note](../../../../../includes/quickstarts-free-trial-note.md)]
2223

23-
- This article requires version 2.0.73 or later of the Azure CLI. If using Azure Cloud Shell, the latest version is already installed.
24+
- This script requires Azure CLI version 2.0.73 or later.
2425

25-
## Sample script
26+
- You can run the script in the Bash environment in [Azure Cloud Shell](../../../../cloud-shell/quickstart.md). When Cloud Shell opens, make sure **Bash** appears in the environment field at the upper left of the shell window. Cloud Shell always has the latest version of Azure CLI.
27+
28+
[![Launch Cloud Shell in a new window](../../../../../includes/media/cloud-shell-try-it/hdi-launch-cloud-shell.png)](https://shell.azure.com)
29+
30+
Cloud Shell is automatically authenticated under the account you used to sign in to the Azure portal. You can use [az account set](/cli/azure/account#az-account-set) to sign in with a different subscription, replacing `<subscriptionId>` with your Azure subscription ID.
31+
32+
```azurecli
33+
subscription="<subscriptionId>" # add subscription here
34+
35+
az account set -s $subscription # ...or use 'az login'
36+
```
37+
38+
- If you prefer, you can [install Azure CLI](/cli/azure/install-azure-cli) to run the script locally. Run [az version](/cli/azure/reference-index?#az-version) to find the Azure CLI version and dependent libraries that are installed, and run [az upgrade](/cli/azure/reference-index?#az-upgrade) if you need to upgrade. If prompted, [install Azure CLI extensions](/cli/azure/azure-cli-extensions-overview). If you're running Windows or macOS, consider [running Azure CLI in a Docker container](/cli/azure/run-azure-cli-docker).
39+
40+
If you're using a local installation, sign in to Azure by running [az login](/cli/azure/reference-index#az-login) and following the prompts. For other sign-in options, see [Sign in with the Azure CLI](/cli/azure/authenticate-azure-cli).
2641
27-
[!INCLUDE [cli-launch-cloud-shell-sign-in.md](../../../../../includes/cli-launch-cloud-shell-sign-in.md)]
42+
## Sample script
2843
29-
### Run the script
44+
Run the following script to create an Azure resource group, an Azure Cosmos DB SQL API account and database, and a container with autoscale. The resources might take a while to create.
3045
3146
:::code language="azurecli" source="~/azure_cli_scripts/cosmosdb/sql/autoscale.sh" id="FullScript":::
3247
48+
This script uses the following commands:
49+
50+
- [az group create](/cli/azure/group#az-group-create) creates a resource group to store all resources.
51+
- [az cosmosdb create](/cli/azure/cosmosdb#az-cosmosdb-create) creates an Azure Cosmos DB account for SQL API.
52+
- [az cosmosdb sql database create](/cli/azure/cosmosdb/sql/database#az-cosmosdb-sql-database-create) creates an Azure Cosmos SQL (Core) database.
53+
- [az cosmosdb sql container create](/cli/azure/cosmosdb/sql/container#az-cosmosdb-sql-container-create) with `--max-throughput 1000` creates an Azure Cosmos SQL (Core) container with autoscale capability.
54+
3355
## Clean up resources
3456
35-
[!INCLUDE [cli-clean-up-resources.md](../../../../../includes/cli-clean-up-resources.md)]
57+
If you no longer need the resources you created, use the [az group delete](/cli/azure/group#az-group-delete) command to delete the resource group and all resources it contains. These resources include the Azure Cosmos DB account, database, and container. The resources might take a while to delete.
3658
3759
```azurecli
3860
az group delete --name $resourceGroup
3961
```
4062

41-
## Sample reference
42-
43-
This script uses the following commands. Each command in the table links to command specific documentation.
44-
45-
| Command | Notes |
46-
|---|---|
47-
| [az group create](/cli/azure/group#az-group-create) | Creates a resource group in which all resources are stored. |
48-
| [az cosmosdb create](/cli/azure/cosmosdb#az-cosmosdb-create) | Creates an Azure Cosmos DB account. |
49-
| [az cosmosdb sql database create](/cli/azure/cosmosdb/sql/database#az-cosmosdb-sql-database-create) | Creates an Azure Cosmos SQL (Core) database. |
50-
| [az cosmosdb sql container create](/cli/azure/cosmosdb/sql/container#az-cosmosdb-sql-container-create) | Creates an Azure Cosmos SQL (Core) container. |
51-
| [az group delete](/cli/azure/resource#az-resource-delete) | Deletes a resource group including all nested resources. |
52-
5363
## Next steps
5464

55-
For more information on the Azure Cosmos DB CLI, see [Azure Cosmos DB CLI documentation](/cli/azure/cosmosdb).
65+
- [Azure Cosmos DB CLI documentation](/cli/azure/cosmosdb)
66+
- [Throughput (RU/s) operations for Azure Cosmos DB Core (SQL) API resources](throughput.md)
Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,65 @@
11
---
2-
title: Create a Table API table with autoscale for Azure Cosmos DB
3-
description: Create a Table API table with autoscale for Azure Cosmos DB
2+
title: Create an Azure Cosmos DB Table API account and table with autoscale
3+
description: Use Azure CLI to create a Table API account and table with autoscale for Azure Cosmos DB.
44
author: seesharprun
55
ms.author: sidandrews
66
ms.reviewer: mjbrown
77
ms.service: cosmos-db
88
ms.subservice: cosmosdb-table
99
ms.topic: sample
10-
ms.date: 02/21/2022
10+
ms.date: 06/22/2022
11+
ms.custom: kr2b-contr-experiment
1112
---
1213

13-
# Create an Azure Cosmos Table API account and table with autoscale using Azure CLI
14+
# Use Azure CLI to create an Azure Cosmos DB Table API account and table with autoscale
1415

1516
[!INCLUDE[appliesto-table-api](../../../includes/appliesto-table-api.md)]
1617

17-
The script in this article demonstrates creating a Table API table with autoscale.
18+
The script in this article creates an Azure Cosmos DB Table API account and table with autoscale.
1819

19-
[!INCLUDE [quickstarts-free-trial-note](../../../../../includes/quickstarts-free-trial-note.md)]
20+
## Prerequisites
2021

21-
[!INCLUDE [azure-cli-prepare-your-environment.md](../../../../../includes/azure-cli-prepare-your-environment.md)]
22+
- [!INCLUDE [quickstarts-free-trial-note](../../../../../includes/quickstarts-free-trial-note.md)]
2223

23-
- This article requires version 2.12.1 or later. Run `az --version` to find the version. If you need to install or upgrade, see [Install Azure CLI](/cli/azure/install-azure-cli). If using Azure Cloud Shell, the latest version is already installed.
24+
- This script requires Azure CLI version 2.12.1 or later.
25+
26+
- You can run the script in the Bash environment in [Azure Cloud Shell](../../../../cloud-shell/quickstart.md). When Cloud Shell opens, make sure **Bash** appears in the environment field at the upper left of the shell window. Cloud Shell always has the latest version of Azure CLI.
27+
28+
[![Launch Cloud Shell in a new window](../../../../../includes/media/cloud-shell-try-it/hdi-launch-cloud-shell.png)](https://shell.azure.com)
29+
30+
Cloud Shell is automatically authenticated under the account you used to sign in to the Azure portal. You can use [az account set](/cli/azure/account#az-account-set) to sign in with a different subscription, replacing `<subscriptionId>` with your Azure subscription ID.
31+
32+
```azurecli
33+
subscription="<subscriptionId>" # add subscription here
34+
35+
az account set -s $subscription # ...or use 'az login'
36+
```
37+
38+
- If you prefer, you can [install Azure CLI](/cli/azure/install-azure-cli) to run the script locally. Run [az version](/cli/azure/reference-index?#az-version) to find the Azure CLI version and dependent libraries that are installed, and run [az upgrade](/cli/azure/reference-index?#az-upgrade) if you need to upgrade. If prompted, [install Azure CLI extensions](/cli/azure/azure-cli-extensions-overview). If you're running Windows or macOS, consider [running Azure CLI in a Docker container](/cli/azure/run-azure-cli-docker).
39+
40+
If you're using a local installation, sign in to Azure by running [az login](/cli/azure/reference-index#az-login) and following the prompts. For other sign-in options, see [Sign in with the Azure CLI](/cli/azure/authenticate-azure-cli).
2441
2542
## Sample script
2643
27-
[!INCLUDE [cli-launch-cloud-shell-sign-in.md](../../../../../includes/cli-launch-cloud-shell-sign-in.md)]
44+
Run the following script to create an Azure resource group, an Azure Cosmos DB Table API account, and Table API table with autoscale capability. The resources might take a while to create.
45+
46+
:::code language="azurecli" source="~/azure_cli_scripts/cosmosdb/table/autoscale.sh" id="FullScript":::
2847
29-
### Run the script
48+
This script uses the following commands:
3049
31-
:::code language="azurecli" source="~/azure_cli_scripts/cosmosdb/table/autoscale.sh" id="FullScript":::
50+
- [az group create](/cli/azure/group#az-group-create) creates a resource group to store all resources.
51+
- [az cosmosdb create](/cli/azure/cosmosdb#az-cosmosdb-create) with `--capabilities EnableTable` creates an Azure Cosmos DB account for Table API.
52+
- [az cosmosdb table create](/cli/azure/cosmosdb/table#az-cosmosdb-table-create) with `--max-throughput 1000` creates an Azure Cosmos DB Table API table with autoscale capabilities.
3253
3354
## Clean up resources
3455
35-
[!INCLUDE [cli-clean-up-resources.md](../../../../../includes/cli-clean-up-resources.md)]
56+
If you no longer need the resources you created, use the [az group delete](/cli/azure/group#az-group-delete) command to delete the resource group and all resources it contains. These resources include the Azure Cosmos DB account and table. The resources might take a while to delete.
3657
3758
```azurecli
3859
az group delete --name $resourceGroup
3960
```
4061

41-
## Sample reference
42-
43-
This script uses the following commands. Each command in the table links to command specific documentation.
44-
45-
| Command | Notes |
46-
|---|---|
47-
| [az group create](/cli/azure/group#az-group-create) | Creates a resource group in which all resources are stored. |
48-
| [az cosmosdb create](/cli/azure/cosmosdb#az-cosmosdb-create) | Creates an Azure Cosmos DB account. |
49-
| [az cosmosdb table create](/cli/azure/cosmosdb/table#az-cosmosdb-table-create) | Creates an Azure Cosmos Table API table. |
50-
| [az group delete](/cli/azure/resource#az-resource-delete) | Deletes a resource group including all nested resources. |
51-
5262
## Next steps
5363

54-
For more information on the Azure Cosmos DB CLI, see [Azure Cosmos DB CLI documentation](/cli/azure/cosmosdb).
64+
- [Azure Cosmos DB CLI documentation](/cli/azure/cosmosdb)
65+
- [Throughput (RU/s) operations with Azure CLI for a table for Azure Cosmos DB Table API](throughput.md)
Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,72 @@
11
---
2-
title: Create resource lock for a Azure Cosmos DB Table API table
3-
description: Create resource lock for a Azure Cosmos DB Table API table
2+
title: Azure Cosmos DB Table API resource lock operations
3+
description: Use Azure CLI to create, list, show properties for, and delete resource locks for an Azure Cosmos DB Table API table.
44
author: seesharprun
55
ms.author: sidandrews
66
ms.reviewer: mjbrown
77
ms.service: cosmos-db
88
ms.subservice: cosmosdb-table
99
ms.topic: sample
10-
ms.date: 02/21/2022
10+
ms.date: 06/16/2022
11+
ms.custom: kr2b-contr-experiment
1112
---
1213

13-
# Create resource lock for a Azure Cosmos DB Table API table using Azure CLI
14+
# Use Azure CLI for resource lock operations on Azure Cosmos DB Table API tables
1415

1516
[!INCLUDE[appliesto-table-api](../../../includes/appliesto-table-api.md)]
1617

17-
The script in this article demonstrates performing resource lock operations for a Table API table.
18+
The script in this article demonstrates performing resource lock operations for a Table API table.
1819

1920
> [!IMPORTANT]
20-
>
21-
> To create resource locks, you must have membership in the owner role in the subscription.
22-
>
23-
> Resource locks do not work for changes made by users connecting Cosmos DB Table SDK, Azure Storage Table SDK, any tools that connect via account keys, or the Azure Portal unless the Cosmos DB account is first locked with the `disableKeyBasedMetadataWriteAccess` property enabled. To learn more about how to enable this property see, [Preventing changes from SDKs](../../../role-based-access-control.md#prevent-sdk-changes).
21+
> To enable resource locking, the Azure Cosmos DB account must have the `disableKeyBasedMetadataWriteAccess` property enabled. This property prevents any changes to resources from clients that connect via account keys, such as the Cosmos DB Table SDK, Azure Storage Table SDK, or Azure portal. For more information, see [Preventing changes from SDKs](../../../role-based-access-control.md#prevent-sdk-changes).
2422
25-
[!INCLUDE [quickstarts-free-trial-note](../../../../../includes/quickstarts-free-trial-note.md)]
23+
## Prerequisites
2624

27-
[!INCLUDE [azure-cli-prepare-your-environment.md](../../../../../includes/azure-cli-prepare-your-environment.md)]
25+
- You need an [Azure Cosmos DB Table API account, database, and table created](create.md). [!INCLUDE [quickstarts-free-trial-note](../../../../../includes/quickstarts-free-trial-note.md)]
2826

29-
- This article requires version 2.12.1 or later. Run `az --version` to find the version. If you need to install or upgrade, see [Install Azure CLI](/cli/azure/install-azure-cli). If using Azure Cloud Shell, the latest version is already installed.
27+
> [!IMPORTANT]
28+
> To create or delete resource locks, you must have the **Owner** role in your Azure subscription.
29+
30+
- This script requires Azure CLI version 2.12.1 or later.
31+
32+
- You can run the script in the Bash environment in [Azure Cloud Shell](../../../../cloud-shell/quickstart.md). When Cloud Shell opens, make sure **Bash** appears in the environment field at the upper left of the shell window. Cloud Shell always has the latest version of Azure CLI.
33+
34+
[![Launch Cloud Shell in a new window](../../../../../includes/media/cloud-shell-try-it/hdi-launch-cloud-shell.png)](https://shell.azure.com)
35+
36+
Cloud Shell is automatically authenticated under the account you used to sign in to the Azure portal. You can use [az account set](/cli/azure/account#az-account-set) to sign in with a different subscription, replacing `<subscriptionId>` with your Azure subscription ID.
37+
38+
```azurecli
39+
subscription="<subscriptionId>" # add subscription here
40+
41+
az account set -s $subscription # ...or use 'az login'
42+
```
43+
44+
- If you prefer, you can [install Azure CLI](/cli/azure/install-azure-cli) to run the script locally. Run [az version](/cli/azure/reference-index?#az-version) to find the Azure CLI version and dependent libraries that are installed, and run [az upgrade](/cli/azure/reference-index?#az-upgrade) if you need to upgrade. If prompted, [install Azure CLI extensions](/cli/azure/azure-cli-extensions-overview). If you're running Windows or macOS, consider [running Azure CLI in a Docker container](/cli/azure/run-azure-cli-docker).
45+
46+
If you're using a local installation, sign in to Azure by running [az login](/cli/azure/reference-index#az-login) and following the prompts. For other sign-in options, see [Sign in with the Azure CLI](/cli/azure/authenticate-azure-cli).
3047
3148
## Sample script
3249
33-
[!INCLUDE [cli-launch-cloud-shell-sign-in.md](../../../../../includes/cli-launch-cloud-shell-sign-in.md)]
50+
The following script uses Azure CLI [az lock](/cli/azure/lock) commands to manipulate resource locks on your Azure Cosmos DB Table API table. The script needs the `resourceGroup`, `account` name, and `table` name for the Azure Cosmos DB account and table you created.
3451
35-
### Run the script
52+
- [az lock create](/cli/azure/lock#az-lock-create) creates a `CanNotDelete` resource lock on the table.
53+
- [az lock list](/cli/azure/lock#az-lock-list) lists all the lock information for your Azure Cosmos DB Table account.
54+
- [az lock delete](/cli/azure/lock#az-lock-delete) uses [az lock show](/cli/azure/lock#az-lock-show) to get the `id` of the lock on your table, and then uses the `lockid` property to delete the lock.
3655
3756
:::code language="azurecli" source="~/azure_cli_scripts/cosmosdb/table/lock.sh" id="FullScript":::
3857
3958
## Clean up resources
4059
41-
[!INCLUDE [cli-clean-up-resources.md](../../../../../includes/cli-clean-up-resources.md)]
60+
If you no longer need the resources you created, use the [az group delete](/cli/azure/group#az-group-delete) command to delete the resource group and all resources it contains. These resources include the Azure Cosmos DB account and table. The resources might take a while to delete.
4261
4362
```azurecli
4463
az group delete --name $resourceGroup
4564
```
4665

47-
## Sample reference
48-
49-
This script uses the following commands. Each command in the table links to command specific documentation.
50-
51-
| Command | Notes |
52-
|---|---|
53-
| [az lock create](/cli/azure/lock#az-lock-create) | Creates a lock. |
54-
| [az lock list](/cli/azure/lock#az-lock-list) | List lock information. |
55-
| [az lock show](/cli/azure/lock#az-lock-show) | Show properties of a lock. |
56-
| [az lock delete](/cli/azure/lock#az-lock-delete) | Deletes a lock. |
57-
5866
## Next steps
5967

60-
- [Lock resources to prevent unexpected changes](../../../../azure-resource-manager/management/lock-resources.md)
61-
62-
- [Azure Cosmos DB CLI documentation](/cli/azure/cosmosdb).
63-
64-
- [Azure Cosmos DB CLI GitHub Repository](https://github.com/Azure-Samples/azure-cli-samples/tree/master/cosmosdb).
68+
- [Prevent Azure Cosmos DB resources from being deleted or changed](../../../resource-locks.md)
69+
- [Lock resources to prevent unexpected changes](/azure/azure-resource-manager/management/lock-resources)
70+
- [How to audit Azure Cosmos DB control plane operations](../../../audit-control-plane-logs.md)
71+
- [Azure Cosmos DB CLI documentation](/cli/azure/cosmosdb)
72+
- [Azure Cosmos DB CLI GitHub repository](https://github.com/Azure-Samples/azure-cli-samples/tree/master/cosmosdb)

0 commit comments

Comments
 (0)