You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/cosmos-db/manage-with-powershell.md
+37-37Lines changed: 37 additions & 37 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
2
title: Create and manage Azure Cosmos DB using PowerShell
3
-
description: Use Azure Powershell manage your Azure Cosmos DB accounts, databases, containers, and throughput.
3
+
description: Use Azure Powershell manage your Azure Cosmos accounts, databases, containers, and throughput.
4
4
author: markjbrown
5
5
ms.service: cosmos-db
6
6
ms.topic: sample
@@ -14,7 +14,7 @@ ms.custom: seodec18
14
14
The following guide describes how to use PowerShell to script and automate management of Azure Cosmos DB resources, including account, database, container, and throughput.
15
15
16
16
> [!NOTE]
17
-
> Samples in this article use `Get-AzResource`/`Set-AzResource` Powershell cmdlets for Azure resource operations as well as [Az.CosmosDB](https://docs.microsoft.com/powershell/module/az.cosmosdb) management cmdlets. Please note that the `Az.CosmosDB` cmdlets are still in preview and may change before release. Please check for updates to `Az.CosmosDB` regularly.
17
+
> Samples in this article use `Get-AzResource` and `Set-AzResource` Powershell cmdlets for Azure resource operations as well as [Az.CosmosDB](https://docs.microsoft.com/powershell/module/az.cosmosdb) management cmdlets. `Az.CosmosDB` cmdlets are still in preview and may change before they are Generally Available. See the [Az.CosmosDB](https://docs.microsoft.com/powershell/module/az.cosmosdb) API reference page for any updates to the commands.
18
18
19
19
To view all of the properties that can be managed using `Get-Resource`/`Set-AzResource` PowerShell cmdlets, see [Azure Cosmos DB resource provider schema](/azure/templates/microsoft.documentdb/allversions)
20
20
@@ -28,23 +28,23 @@ Follow the instructions in [How to install and configure Azure PowerShell][power
28
28
29
29
*`Set-AzureResource` is used below. It will ask for user confirmation. If you prefer to execute without requiring user confirmation, append the `-Force` flag to the command.
30
30
31
-
## Azure Cosmos DB Accounts
31
+
## Azure Cosmos accounts
32
32
33
-
The following sections demonstrate how to manage the Azure Cosmos DB account, including:
33
+
The following sections demonstrate how to manage the Azure Cosmos account, including:
34
34
35
-
*[Create an Azure Cosmos DB account](#create-account)
36
-
*[Update an Azure Cosmos DB account](#update-account)
37
-
*[List all Azure Cosmos DB accounts in a subscription](#list-accounts)
38
-
*[Get an Azure Cosmos DB account](#get-account)
39
-
*[Delete an Azure Cosmos DB account](#delete-account)
40
-
*[Update tags for an Azure Cosmos DB account](#update-tags)
41
-
*[List keys for an Azure Cosmos DB account](#list-keys)
42
-
*[Regenerate keys for an Azure Cosmos DB account](#regenerate-keys)
43
-
*[List connection strings for an Azure Cosmos DB account](#list-connection-strings)
44
-
*[Modify failover priority for an Azure Cosmos DB account](#modify-failover-priority)
45
-
*[Trigger a manual failover for an Azure Cosmos DB account](#trigger-manual-failover)
35
+
*[Create an Azure Cosmos account](#create-account)
36
+
*[Update an Azure Cosmos account](#update-account)
37
+
*[List all Azure Cosmos accounts in a subscription](#list-accounts)
38
+
*[Get an Azure Cosmos account](#get-account)
39
+
*[Delete an Azure Cosmos account](#delete-account)
40
+
*[Update tags for an Azure Cosmos account](#update-tags)
41
+
*[List keys for an Azure Cosmos account](#list-keys)
42
+
*[Regenerate keys for an Azure Cosmos account](#regenerate-keys)
43
+
*[List connection strings for an Azure Cosmos account](#list-connection-strings)
44
+
*[Modify failover priority for an Azure Cosmos account](#modify-failover-priority)
45
+
*[Trigger a manual failover for an Azure Cosmos account](#trigger-manual-failover)
46
46
47
-
### <aid="create-account"></a> Create an Azure Cosmos DB account
47
+
### <aid="create-account"></a> Create an Azure Cosmos account
48
48
49
49
This command creates an Azure Cosmos DB database account with [multiple regions][distribute-data-globally], [automatic failover](how-to-manage-database-account.md#automatic-failover) and bounded-staleness [consistency policy](consistency-levels.md).
*`$resourceGroupName` The Azure resource group into which to deploy the Cosmos account. It must already exist.
69
69
*`$locations` The regions for the database account, starting with the write region and ordered by failover priority.
70
-
*`$accountName` The name for the Azure Cosmos DB account. Must be unique, lowercase, include only alphanumeric and '-' characters, and between 3 and 31 characters in length.
70
+
*`$accountName` The name for the Azure Cosmos account. Must be unique, lowercase, include only alphanumeric and '-' characters, and between 3 and 31 characters in length.
71
71
*`$apiKind` The type of Cosmos account to create. For more information, see [APIs in Cosmos DB](introduction.md#develop-applications-on-cosmos-db-using-popular-open-source-software-oss-apis).
72
-
*`$consistencyPolicy`, `$maxStalenessInterval`, and `$maxStalenessPrefix` The default consistency level and settings of the Azure Cosmos DB account. For more information, see [Consistency Levels in Azure Cosmos DB](consistency-levels.md).
72
+
*`$consistencyPolicy`, `$maxStalenessInterval`, and `$maxStalenessPrefix` The default consistency level and settings of the Azure Cosmos account. For more information, see [Consistency Levels in Azure Cosmos DB](consistency-levels.md).
73
73
74
-
Azure Cosmos DB accounts can be configured with IP Firewall, Virtual Network service endpoints, and private endpoints. For information on how to configure the IP Firewall for Azure Cosmos DB, see [Configure IP Firewall](how-to-configure-firewall.md). For information on how to enable service endpoints for Azure Cosmos DB, see [Configure access from virtual Networks](how-to-configure-vnet-service-endpoint.md). For information on how to enable private endpoints for Azure Cosmos DB, see [Configure access from private endpoints](how-to-configure-private-endpoints.md).
74
+
Azure Cosmos accounts can be configured with IP Firewall, Virtual Network service endpoints, and private endpoints. For information on how to configure the IP Firewall for Azure Cosmos DB, see [Configure IP Firewall](how-to-configure-firewall.md). For information on how to enable service endpoints for Azure Cosmos DB, see [Configure access from virtual Networks](how-to-configure-vnet-service-endpoint.md). For information on how to enable private endpoints for Azure Cosmos DB, see [Configure access from private endpoints](how-to-configure-private-endpoints.md).
75
75
76
-
### <aid="list-accounts"></a> List all Azure Cosmos DB accounts in a Resource Group
76
+
### <aid="list-accounts"></a> List all Azure Cosmos accounts in a Resource Group
77
77
78
-
This command lists all Azure Cosmos DB accounts in a Resource Group.
78
+
This command lists all Azure Cosmos accounts in a Resource Group.
### <aid="update-account"></a> Update an Azure Cosmos DB account
97
+
### <aid="update-account"></a> Update an Azure Cosmos account
98
98
99
99
This command allows you to update your Azure Cosmos DB database account properties. Properties that can be updated include the following:
100
100
@@ -105,7 +105,7 @@ This command allows you to update your Azure Cosmos DB database account properti
105
105
* Enabling Multi-master
106
106
107
107
> [!NOTE]
108
-
> You cannot simultaneously add or remove regions `locations` and change other properties for an Azure Cosmos DB account. Modifying regions must be performed as a separate operation from any other change to the account.
108
+
> You cannot simultaneously add or remove regions `locations` and change other properties for an Azure Cosmos account. Modifying regions must be performed as a separate operation from any other change to the account.
109
109
> [!NOTE]
110
110
> This command allows you to add and remove regions but does not allow you to modify failover priorities or trigger a manual failover. See [Modify failover priority](#modify-failover-priority) and [Trigger manual failover](#trigger-manual-failover).
Write-Host "Set-AzResource returns before the region update is complete."
170
170
Write-Host "Check account in Azure portal or using Get-AzCosmosDBAccount for region status."
171
171
```
172
-
### <aid="multi-master"></a> Enable multiple write regions for an Azure Cosmos DB account
172
+
### <aid="multi-master"></a> Enable multiple write regions for an Azure Cosmos account
173
173
174
174
```azurepowershell-interactive
175
175
$resourceGroupName = "myResourceGroup"
@@ -191,9 +191,9 @@ Update-AzCosmosDBAccount `
191
191
-EnableMultipleWriteLocations:$enableMultiMaster
192
192
```
193
193
194
-
### <aid="delete-account"></a> Delete an Azure Cosmos DB account
194
+
### <aid="delete-account"></a> Delete an Azure Cosmos account
195
195
196
-
This command deletes an existing Azure Cosmos DB account.
196
+
This command deletes an existing Azure Cosmos account.
197
197
198
198
```azurepowershell-interactive
199
199
$resourceGroupName = "myResourceGroup"
@@ -204,9 +204,9 @@ Remove-AzCosmosDBAccount `
204
204
-Name $accountName -PassThru
205
205
```
206
206
207
-
### <aid="update-tags"></a> Update Tags of an Azure Cosmos DB account
207
+
### <aid="update-tags"></a> Update Tags of an Azure Cosmos account
208
208
209
-
This command sets the [Azure resource tags][azure-resource-tags] for an Azure Cosmos DB account. Tags can be set both at account creation using `New-AzCosmosDBAccount` as well as on account update using `Update-AzCosmosDBAccount`.
209
+
This command sets the [Azure resource tags][azure-resource-tags] for an Azure Cosmos account. Tags can be set both at account creation using `New-AzCosmosDBAccount` as well as on account update using `Update-AzCosmosDBAccount`.
210
210
211
211
```azurepowershell-interactive
212
212
$resourceGroupName = "myResourceGroup"
@@ -220,8 +220,8 @@ Update-AzCosmosDBAccount `
220
220
221
221
### <aid="list-keys"></a> List Account Keys
222
222
223
-
When you create an Azure Cosmos DB account, the service generates two master access keys that can be used for authentication when the Azure Cosmos DB account is accessed. Read-only keys for authenticating read-only operations are also generated.
224
-
By providing two access keys, Azure Cosmos DB enables you to regenerate and rotate one key at a time with no interruption to your Azure Cosmos DB account.
223
+
When you create an Azure Cosmos account, the service generates two master access keys that can be used for authentication when the Azure Cosmos account is accessed. Read-only keys for authenticating read-only operations are also generated.
224
+
By providing two access keys, Azure Cosmos DB enables you to regenerate and rotate one key at a time with no interruption to your Azure Cosmos account.
225
225
Cosmos DB accounts have two read-write keys (primary and secondary) and two read-only keys (primary and secondary).
Access keys to an Azure Cosmos DB account should be periodically regenerated to help keep connections secure. A primary and secondary access keys are assigned to the account. This allows clients to maintain access while one key at a time is regenerated.
252
-
There are four types of keys for an Azure Cosmos DB account (Primary, Secondary, PrimaryReadonly, and SecondaryReadonly)
251
+
Access keys to an Azure Cosmos account should be periodically regenerated to help keep connections secure. A primary and secondary access keys are assigned to the account. This allows clients to maintain access while one key at a time is regenerated.
252
+
There are four types of keys for an Azure Cosmos account (Primary, Secondary, PrimaryReadonly, and SecondaryReadonly)
253
253
254
254
```azurepowershell-interactive
255
255
$resourceGroupName = "myResourceGroup" # Resource Group must already exist
@@ -292,7 +292,7 @@ For accounts configured with Automatic Failover, you can change the order in whi
292
292
For the example below, assume the current failover priority is `West US 2 = 0`, `East US 2 = 1`, `South Central US = 2`. The command will change this to `West US 2 = 0`, `South Central US = 1`, `East US 2 = 2`.
293
293
294
294
> [!CAUTION]
295
-
> Changing the location for `failoverPriority=0` will trigger a manual failover for an Azure Cosmos DB account. Any other priority changes will not trigger a failover.
295
+
> Changing the location for `failoverPriority=0` will trigger a manual failover for an Azure Cosmos account. Any other priority changes will not trigger a failover.
296
296
297
297
```azurepowershell-interactive
298
298
$resourceGroupName = "myResourceGroup"
@@ -312,7 +312,7 @@ For accounts configured with Manual Failover, you can fail over and promote any
312
312
For the example below, assume the account has a current failover priority of `West US 2 = 0` and `East US 2 = 1` and flip the regions.
313
313
314
314
> [!CAUTION]
315
-
> Changing `locationName` for `failoverPriority=0` will trigger a manual failover for an Azure Cosmos DB account. Any other priority change will not trigger a failover.
315
+
> Changing `locationName` for `failoverPriority=0` will trigger a manual failover for an Azure Cosmos account. Any other priority change will not trigger a failover.
0 commit comments