Skip to content

Commit 59bcbfa

Browse files
Merge pull request #89111 from markjbrown/mjbrown-ps-cleanup
Clean up for cosmos PowerShell docs and scripts
2 parents a5dc33b + bae3568 commit 59bcbfa

16 files changed

+131
-250
lines changed

.openpublishing.redirection.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,6 +1545,26 @@
15451545
"redirect_url": "/azure/cosmos-db/powershell-samples-sql",
15461546
"redirect_document_id": true
15471547
},
1548+
{
1549+
"source_path": "articles/cosmos-db/scripts/powershell/create-and-configure-cassandra-database.md",
1550+
"redirect_url": "/azure/cosmos-db/powershell-samples-cassandra",
1551+
"redirect_document_id": false
1552+
},
1553+
{
1554+
"source_path": "articles/cosmos-db/scripts/powershell/create-graph-database-account-powershell.md",
1555+
"redirect_url": "/azure/cosmos-db/powershell-samples-gremlin",
1556+
"redirect_document_id": false
1557+
},
1558+
{
1559+
"source_path": "articles/cosmos-db/scripts/powershell/create-mongodb-database-account-powershell.md",
1560+
"redirect_url": "/azure/cosmos-db/powershell-samples-mongodb",
1561+
"redirect_document_id": false
1562+
},
1563+
{
1564+
"source_path": "articles/cosmos-db/scripts/powershell/create-table-database-account-powershell.md",
1565+
"redirect_url": "/azure/cosmos-db/powershell-samples-table",
1566+
"redirect_document_id": false
1567+
},
15481568
{
15491569
"source_path": "articles/cosmos-db/scripts/powershell/sql/ps-account-delete.md",
15501570
"redirect_url": "/azure/cosmos-db/powershell-samples-sql",

articles/cosmos-db/manage-with-powershell.md

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ The following sections demonstrate how to manage the Azure Cosmos account, inclu
3838
* [Regenerate keys for an Azure Cosmos account](#regenerate-keys)
3939
* [List connection strings for an Azure Cosmos account](#list-connection-strings)
4040
* [Modify failover priority for an Azure Cosmos account](#modify-failover-priority)
41+
* [Trigger a manual failover for an Azure Cosmos account](#trigger-manual-failover)
4142

4243
### <a id="create-account"></a> Create an Azure Cosmos account
4344

@@ -116,7 +117,9 @@ This command allows you to update your Azure Cosmos database account properties.
116117
* Enabling Multi-master
117118

118119
> [!NOTE]
119-
> This command allows you to add and remove regions but does not allow you to modify failover priorities or change the region with `failoverPriority=0`. To modify failover priority, see [Modify failover priority for an Azure Cosmos account](#modify-failover-priority).
120+
> 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 than any other change to the account resource.
121+
> [!NOTE]
122+
> 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).
120123
121124
```azurepowershell-interactive
122125
# Get an Azure Cosmos Account (assume it has two regions currently West US 2 and East US 2) and add a third region
@@ -233,23 +236,55 @@ Select-Object $keys
233236

234237
### <a id="modify-failover-priority"></a> Modify Failover Priority
235238

236-
For multi-region database accounts, you can change the order in which a Cosmos account will promote secondary read-replicas should a regional failover occur on the primary write replica. Modifying `failoverPriority=0` can also be used to initiate a disaster recovery drill to test disaster recovery planning.
239+
For accounts configured with Automatic Failover, you can change the order in which Cosmos will promote secondary replicas to primary should the primary become unavailable.
237240

238-
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.
241+
For the example below, assume the current failover priority, `West US 2 = 0`, `East US 2 = 1`, `South Central US = 2`.
239242

240243
> [!CAUTION]
241244
> Changing `locationName` for `failoverPriority=0` will trigger a manual failover for an Azure Cosmos account. Any other priority changes will not trigger a failover.
242245
243246
```azurepowershell-interactive
244247
# Change the failover priority for an Azure Cosmos Account
245-
# Assume existing priority is "West US 2" = 0 and "East US 2" = 1
248+
# Assume existing priority is "West US 2" = 0, "East US 2" = 1, "South Central US" = 2
249+
250+
$resourceGroupName = "myResourceGroup"
251+
$accountName = "mycosmosaccount"
252+
253+
$failoverRegions = @(
254+
@{ "locationName"="West US 2"; "failoverPriority"=0 },
255+
@{ "locationName"="South Central US"; "failoverPriority"=1 },
256+
@{ "locationName"="East US 2"; "failoverPriority"=2 }
257+
)
258+
259+
$failoverPolicies = @{
260+
"failoverPolicies"= $failoverRegions
261+
}
262+
263+
Invoke-AzResourceAction -Action failoverPriorityChange `
264+
-ResourceType "Microsoft.DocumentDb/databaseAccounts" -ApiVersion "2015-04-08" `
265+
-ResourceGroupName $resourceGroupName -Name $accountName -Parameters $failoverPolicies
266+
```
267+
268+
### <a id="trigger-manual-failover"></a> Trigger Manual Failover
269+
270+
For accounts configured with Manual Failover, you can failover and promote any secondary replica to primary by modifying to `failoverPriority=0`. This operation can be used to initiate a disaster recovery drill to test disaster recovery planning.
271+
272+
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.
273+
274+
> [!CAUTION]
275+
> Changing `locationName` for `failoverPriority=0` will trigger a manual failover for an Azure Cosmos account. Any other priority change will not trigger a failover.
276+
277+
```azurepowershell-interactive
278+
# Change the failover priority for an Azure Cosmos Account
279+
# Assume existing priority is "West US 2" = 0, "East US 2" = 1, "South Central US" = 2
246280
247281
$resourceGroupName = "myResourceGroup"
248282
$accountName = "mycosmosaccount"
249283
250284
$failoverRegions = @(
251-
@{ "locationName"="East US 2"; "failoverPriority"=0 },
252-
@{ "locationName"="West US 2"; "failoverPriority"=1 }
285+
@{ "locationName"="South Central US"; "failoverPriority"=0 },
286+
@{ "locationName"="East US 2"; "failoverPriority"=1 },
287+
@{ "locationName"="West US 2"; "failoverPriority"=2 }
253288
)
254289
255290
$failoverPolicies = @{

articles/cosmos-db/powershell-samples-cassandra.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Azure PowerShell samples for Azure Cosmos DB - Cassandra API
44
author: markjbrown
55
ms.service: cosmos-db
66
ms.topic: sample
7-
ms.date: 07/03/2019
7+
ms.date: 09/20/2019
88
ms.author: mjbrown
99
---
1010

@@ -18,7 +18,8 @@ The following table includes links to sample Azure PowerShell scripts for Azure
1818
|[List or get keyspaces or tables](scripts/powershell/cassandra/ps-cassandra-list-get.md?toc=%2fpowershell%2fmodule%2ftoc.json)| List or get keyspaces or tables. |
1919
|[Get RU/s](scripts/powershell/cassandra/ps-cassandra-ru-get.md?toc=%2fpowershell%2fmodule%2ftoc.json)| Get RU/s for a keyspace or table. |
2020
|[Update RU/s](scripts/powershell/cassandra/ps-cassandra-ru-update.md?toc=%2fpowershell%2fmodule%2ftoc.json)| Update RU/s for a keyspace or table. |
21-
|[Add a region](scripts/powershell/common/ps-account-update.md?toc=%2fpowershell%2fmodule%2ftoc.json)| Get an Azure Cosmos account and add a region to the list of locations. |
22-
|[Change the failover priority](scripts/powershell/common/ps-account-failover-priority-update.md?toc=%2fpowershell%2fmodule%2ftoc.json)| Change the failover priority of an Azure Cosmos account with a manual failover trigger. |
23-
|[Account keys and connection string tasks](scripts/powershell/common/ps-account-keys-connection-strings.md?toc=%2fpowershell%2fmodule%2ftoc.json)| Get the connection strings for an Azure Cosmos account. Get the primary and secondary keys of an Azure Cosmos account. Regenerate an account key. |
21+
|[Update an account or add a region](scripts/powershell/common/ps-account-update.md?toc=%2fpowershell%2fmodule%2ftoc.json)| Add a region to a Cosmos account. Can also be used to modify other account properties but these must be separate from changes to regions. |
22+
|[Change failover priority or trigger failover](scripts/powershell/common/ps-account-failover-priority-update.md?toc=%2fpowershell%2fmodule%2ftoc.json)| Change the regional failover priority of an Azure Cosmos account or trigger a manual failover. |
23+
|[Account keys or connection strings](scripts/powershell/common/ps-account-keys-connection-strings.md?toc=%2fpowershell%2fmodule%2ftoc.json)| Get primary and secondary keys, connection strings or regenerate an account key of an Azure Cosmos account. |
24+
|[Create a Cosmos Account with IP Firewall](scripts/powershell/common/ps-account-firewall-create.md?toc=%2fpowershell%2fmodule%2ftoc.json)| Create an Azure Cosmos account with IP Firewall enabled. |
2425
|||

articles/cosmos-db/powershell-samples-gremlin.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Azure PowerShell samples for Azure Cosmos DB - Gremlin API
44
author: markjbrown
55
ms.service: cosmos-db
66
ms.topic: sample
7-
ms.date: 07/03/2019
7+
ms.date: 09/20/2019
88
ms.author: mjbrown
99
---
1010

@@ -18,7 +18,8 @@ The following table includes links to sample Azure PowerShell scripts for Azure
1818
|[List or get databases or graphs](scripts/powershell/gremlin/ps-gremlin-list-get.md?toc=%2fpowershell%2fmodule%2ftoc.json)| List or get database or graph. |
1919
|[Get RU/s](scripts/powershell/gremlin/ps-gremlin-ru-get.md?toc=%2fpowershell%2fmodule%2ftoc.json)| Get RU/s for a database or graph. |
2020
|[Update RU/s](scripts/powershell/gremlin/ps-gremlin-ru-update.md?toc=%2fpowershell%2fmodule%2ftoc.json)| Update RU/s for a database or graph. |
21-
|[Add a region](scripts/powershell/common/ps-account-update.md?toc=%2fpowershell%2fmodule%2ftoc.json)| Get an Azure Cosmos account and add a region to the list of locations. |
22-
|[Change the failover priority](scripts/powershell/common/ps-account-failover-priority-update.md?toc=%2fpowershell%2fmodule%2ftoc.json)| Change the failover priority of an Azure Cosmos account with a manual failover trigger. |
23-
|[Account keys and connection string tasks](scripts/powershell/common/ps-account-keys-connection-strings.md?toc=%2fpowershell%2fmodule%2ftoc.json)| Get the connection strings for an Azure Cosmos account. Get the primary and secondary keys of an Azure Cosmos account. Regenerate an account key. |
21+
|[Update an account or add a region](scripts/powershell/common/ps-account-update.md?toc=%2fpowershell%2fmodule%2ftoc.json)| Add a region to a Cosmos account. Can also be used to modify other account properties but these must be separate from changes to regions. |
22+
|[Change failover priority or trigger failover](scripts/powershell/common/ps-account-failover-priority-update.md?toc=%2fpowershell%2fmodule%2ftoc.json)| Change the regional failover priority of an Azure Cosmos account or trigger a manual failover. |
23+
|[Account keys or connection strings](scripts/powershell/common/ps-account-keys-connection-strings.md?toc=%2fpowershell%2fmodule%2ftoc.json)| Get primary and secondary keys, connection strings or regenerate an account key of an Azure Cosmos account. |
24+
|[Create a Cosmos Account with IP Firewall](scripts/powershell/common/ps-account-firewall-create.md?toc=%2fpowershell%2fmodule%2ftoc.json)| Create an Azure Cosmos account with IP Firewall enabled. |
2425
|||

articles/cosmos-db/powershell-samples-mongodb.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Azure PowerShell samples for Azure Cosmos DB - MongoDB API
44
author: markjbrown
55
ms.service: cosmos-db
66
ms.topic: sample
7-
ms.date: 07/03/2019
7+
ms.date: 09/20/2019
88
ms.author: mjbrown
99
---
1010

@@ -18,7 +18,8 @@ The following table includes links to sample Azure PowerShell scripts for Azure
1818
|[List or get databases or collections](scripts/powershell/mongodb/ps-mongodb-list-get.md?toc=%2fpowershell%2fmodule%2ftoc.json)| List or get database or collection. |
1919
|[Get RU/s](scripts/powershell/mongodb/ps-mongodb-ru-get.md?toc=%2fpowershell%2fmodule%2ftoc.json)| Get RU/s for a database or collection. |
2020
|[Update RU/s](scripts/powershell/mongodb/ps-mongodb-ru-update.md?toc=%2fpowershell%2fmodule%2ftoc.json)| Update RU/s for a database or collection. |
21-
|[Add a region](scripts/powershell/common/ps-account-update.md?toc=%2fpowershell%2fmodule%2ftoc.json)| Get an Azure Cosmos account and add a region to the list of locations. |
22-
|[Change the failover priority](scripts/powershell/common/ps-account-failover-priority-update.md?toc=%2fpowershell%2fmodule%2ftoc.json)| Change the failover priority of an Azure Cosmos account with a manual failover trigger. |
23-
|[Account keys and connection string tasks](scripts/powershell/common/ps-account-keys-connection-strings.md?toc=%2fpowershell%2fmodule%2ftoc.json)| Get the connection strings for an Azure Cosmos account. Get the primary and secondary keys of an Azure Cosmos account. Regenerate an account key. |
21+
|[Update an account or add a region](scripts/powershell/common/ps-account-update.md?toc=%2fpowershell%2fmodule%2ftoc.json)| Add a region to a Cosmos account. Can also be used to modify other account properties but these must be separate from changes to regions. |
22+
|[Change failover priority or trigger failover](scripts/powershell/common/ps-account-failover-priority-update.md?toc=%2fpowershell%2fmodule%2ftoc.json)| Change the regional failover priority of an Azure Cosmos account or trigger a manual failover. |
23+
|[Account keys or connection strings](scripts/powershell/common/ps-account-keys-connection-strings.md?toc=%2fpowershell%2fmodule%2ftoc.json)| Get primary and secondary keys, connection strings or regenerate an account key of an Azure Cosmos account. |
24+
|[Create a Cosmos Account with IP Firewall](scripts/powershell/common/ps-account-firewall-create.md?toc=%2fpowershell%2fmodule%2ftoc.json)| Create an Azure Cosmos account with IP Firewall enabled. |
2425
|||

articles/cosmos-db/powershell-samples-sql.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ description: Azure PowerShell samples for Azure Cosmos DB - SQL (Core) API
44
author: markjbrown
55
ms.service: cosmos-db
66
ms.topic: sample
7-
ms.date: 07/03/2019
7+
ms.date: 09/20/2019
88
ms.author: mjbrown
99
---
1010

11-
# Azure PowerShell samples for Azure Cosmos DB SQL (Core) API
11+
# Azure PowerShell samples for Azure Cosmos DB - SQL (Core) API
1212

13-
The following table includes links to commonly used Azure PowerShell scripts for Azure Cosmos DB for SQL (Core) API.. For a complete listing of all PowerShell scripts see, [Cosmos DB PowerShell Samples for SQL (Core) API on GitHub](https://github.com/Azure/azure-docs-powershell-samples/tree/master/cosmosdb/sql)
13+
The following table includes links to commonly used Azure PowerShell scripts for Azure Cosmos DB for SQL (Core) API. If you'd like to fork these PowerShell samples for Cosmos DB from our GitHub repository visit, [Cosmos DB PowerShell Samples on GitHub](https://github.com/Azure/azure-docs-powershell-samples/tree/master/cosmosdb).
14+
15+
For additional Cosmos DB PowerShell samples for SQL (Core) API and documentation see, [Manage Azure Cosmos DB SQL API resources using PowerShell](manage-with-powershell.md). For Cosmos DB PowerShell samples for other APIs see, [Cassandra API](powershell-samples-cassandra.md), [MongoDB API](powershell-samples-mongodb.md), [Gremlin API](powershell-samples-gremlin.md), and [Table API](powershell-samples-table.md).
1416

1517
| | |
1618
|---|---|
@@ -19,8 +21,9 @@ The following table includes links to commonly used Azure PowerShell scripts for
1921
|[List or get databases or containers](scripts/powershell/sql/ps-sql-list-get.md?toc=%2fpowershell%2fmodule%2ftoc.json)| List or get database or containers. |
2022
|[Get RU/s](scripts/powershell/sql/ps-sql-ru-get.md?toc=%2fpowershell%2fmodule%2ftoc.json)| Get RU/s for a database or container. |
2123
|[Update RU/s](scripts/powershell/sql/ps-sql-ru-update.md?toc=%2fpowershell%2fmodule%2ftoc.json)| Update RU/s for a database or container. |
22-
|[Add a region](scripts/powershell/common/ps-account-update.md?toc=%2fpowershell%2fmodule%2ftoc.json)| Get an Azure Cosmos account and add a region to the list of locations. |
2324
|[Create a container with no index policy](scripts/powershell/sql/ps-sql-container-create-index-none.md?toc=%2fpowershell%2fmodule%2ftoc.json) | Create an Azure Cosmos container with index policy turned off.|
24-
|[Change the failover priority](scripts/powershell/common/ps-account-failover-priority-update.md?toc=%2fpowershell%2fmodule%2ftoc.json)| Change the failover priority of an Azure Cosmos account with a manual failover trigger. |
25-
|[Account keys and connection string tasks](scripts/powershell/common/ps-account-keys-connection-strings.md?toc=%2fpowershell%2fmodule%2ftoc.json)| Get the connection strings for an Azure Cosmos account. Get the primary and secondary keys of an Azure Cosmos account. Regenerate an account key. |
25+
|[Update an account or add a region](scripts/powershell/common/ps-account-update.md?toc=%2fpowershell%2fmodule%2ftoc.json)| Add a region to a Cosmos account. Can also be used to modify other account properties but these must be separate from changes to regions. |
26+
|[Change failover priority or trigger failover](scripts/powershell/common/ps-account-failover-priority-update.md?toc=%2fpowershell%2fmodule%2ftoc.json)| Change the regional failover priority of an Azure Cosmos account or trigger a manual failover. |
27+
|[Account keys or connection strings](scripts/powershell/common/ps-account-keys-connection-strings.md?toc=%2fpowershell%2fmodule%2ftoc.json)| Get primary and secondary keys, connection strings or regenerate an account key of an Azure Cosmos account. |
28+
|[Create a Cosmos Account with IP Firewall](scripts/powershell/common/ps-account-firewall-create.md?toc=%2fpowershell%2fmodule%2ftoc.json)| Create an Azure Cosmos account with IP Firewall enabled. |
2629
|||

articles/cosmos-db/powershell-samples-table.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Azure PowerShell samples for Azure Cosmos DB - Table API
44
author: markjbrown
55
ms.service: cosmos-db
66
ms.topic: sample
7-
ms.date: 07/03/2019
7+
ms.date: 09/20/2019
88
ms.author: mjbrown
99
---
1010

@@ -18,7 +18,8 @@ The following table includes links to sample Azure PowerShell scripts for Azure
1818
|[List or get tables](scripts/powershell/table/ps-table-list-get.md?toc=%2fpowershell%2fmodule%2ftoc.json)| List or get tables. |
1919
|[Get RU/s](scripts/powershell/table/ps-table-ru-get.md?toc=%2fpowershell%2fmodule%2ftoc.json)| Get RU/s for a table. |
2020
|[Update RU/s](scripts/powershell/table/ps-table-ru-update.md?toc=%2fpowershell%2fmodule%2ftoc.json)| Update RU/s for a table. |
21-
|[Add a region](scripts/powershell/common/ps-account-update.md?toc=%2fpowershell%2fmodule%2ftoc.json)| Get an Azure Cosmos account and add a region to the list of locations. |
22-
|[Change the failover priority](scripts/powershell/common/ps-account-failover-priority-update.md?toc=%2fpowershell%2fmodule%2ftoc.json)| Change the failover priority of an Azure Cosmos account with a manual failover trigger. |
23-
|[Account keys and connection string tasks](scripts/powershell/common/ps-account-keys-connection-strings.md?toc=%2fpowershell%2fmodule%2ftoc.json)| Get the connection strings for an Azure Cosmos account. Get the primary and secondary keys of an Azure Cosmos account. Regenerate an account key. |
21+
|[Update an account or add a region](scripts/powershell/common/ps-account-update.md?toc=%2fpowershell%2fmodule%2ftoc.json)| Add a region to a Cosmos account. Can also be used to modify other account properties but these must be separate from changes to regions. |
22+
|[Change failover priority or trigger failover](scripts/powershell/common/ps-account-failover-priority-update.md?toc=%2fpowershell%2fmodule%2ftoc.json)| Change the regional failover priority of an Azure Cosmos account or trigger a manual failover. |
23+
|[Account keys or connection strings](scripts/powershell/common/ps-account-keys-connection-strings.md?toc=%2fpowershell%2fmodule%2ftoc.json)| Get primary and secondary keys, connection strings or regenerate an account key of an Azure Cosmos account. |
24+
|[Create a Cosmos Account with IP Firewall](scripts/powershell/common/ps-account-firewall-create.md?toc=%2fpowershell%2fmodule%2ftoc.json)| Create an Azure Cosmos account with IP Firewall enabled. |
2425
|||

0 commit comments

Comments
 (0)