Skip to content

Commit 7d05202

Browse files
authored
Merge pull request #98338 from msebolt/powershell-update-pr5
powershell updates
2 parents f1ad5db + e3e46ee commit 7d05202

16 files changed

+892
-38
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
title: CLI example- Failover group - Azure SQL Database elastic pool
3+
description: Azure CLI example script to create an Azure SQL Database elastic pool, add it to a failover group, and test failover.
4+
services: sql-database
5+
ms.service: sql-database
6+
ms.subservice: high-availability
7+
ms.custom:
8+
ms.devlang: azurecli
9+
ms.topic: sample
10+
author: MashaMSFT
11+
ms.author: mathoma
12+
ms.reviewer: carlrab
13+
ms.date: 07/16/2019
14+
---
15+
# Use CLI to add an Azure SQL Database elastic pool to a failover group
16+
17+
This Azure CLI script example creates a single database, adds it to an elastic pool, creates a failover group, and tests failover.
18+
19+
If you choose to install and use the CLI locally, this article requires that you are running the Azure CLI version 2.0 or later. Run `az --version` to find the version. If you need to install or upgrade, see [Install the Azure CLI](/cli/azure/install-azure-cli).
20+
21+
## Sample script
22+
23+
[!INCLUDE [quickstarts-free-trial-note](../../../includes/quickstarts-free-trial-note.md)]
24+
25+
### Sign in to Azure
26+
27+
```azurecli-interactive
28+
$subscription = "<subscriptionId>" # add subscription here
29+
30+
az account set -s $subscription # ...or use 'az login'
31+
```
32+
33+
### Run the script
34+
35+
[!code-azurecli-interactive[main](../../../cli_scripts/sql-database/failover-groups/add-elastic-pool-to-failover-group-az-cli.sh "Add elastic pool to a failover group")]
36+
37+
### Clean up deployment
38+
39+
Use the following command to remove the resource group and all resources associated with it.
40+
41+
```azurecli-interactive
42+
az group delete --name $resourceGroup
43+
```
44+
45+
## Script explanation
46+
47+
This script uses the following commands.
48+
49+
| Command | Notes |
50+
|---|---|
51+
| [az sql elastic-pool](/cli/azure/sql/elastic-pool) | Creates an elastic database pool for a an Azure SQL Database. |
52+
| [az sql failover-group ](/cli/azure/sql/failover-group) | Creates a new failover group. |
53+
54+
## Next steps
55+
56+
For more information on the Azure CLI, see [Azure CLI documentation](/cli/azure/overview).
57+
58+
Additional SQL Database Azure CLI script samples can be found in the [Azure SQL Database Azure CLI scripts](../sql-database-cli-samples.md).
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
title: CLI example- Failover group - Azure SQL Database managed instance
3+
description: Azure CLI example script to create an Azure SQL Database managed instance, add it to a failover group, and test failover.
4+
services: sql-database
5+
ms.service: sql-database
6+
ms.subservice: high-availability
7+
ms.custom:
8+
ms.devlang: azurecli
9+
ms.topic: sample
10+
author: MashaMSFT
11+
ms.author: mathoma
12+
ms.reviewer: carlrab
13+
ms.date: 07/16/2019
14+
---
15+
# Use CLI to add an Azure SQL Database managed instance to a failover group
16+
17+
This PowerShell script example creates two managed instances, adds them to a failover group, and then tests failover from the primary managed instance to the secondary managed instance.
18+
19+
[!INCLUDE [quickstarts-free-trial-note](../../../includes/quickstarts-free-trial-note.md)]
20+
21+
[!INCLUDE [cloud-shell-try-it.md](../../../includes/cloud-shell-try-it.md)]
22+
23+
If you choose to install and use the CLI locally, this article requires that you are running the Azure CLI version 2.0 or later. Run `az --version` to find the version. If you need to install or upgrade, see [Install the Azure CLI](/cli/azure/install-azure-cli).
24+
25+
## Sample scripts
26+
27+
[!code-azurecli-interactive[main](../../../cli_scripts/sql-database/failover-groups/add-managed-instance-to-failover-group-az-cli.sh "Add managed instance to a failover group")]
28+
29+
## Clean up deployment
30+
31+
Use the following command to remove the resource group and all resources associated with it. You will need to remove the resource group twice. Removing the resource group the first time will remove the managed instance and virtual clusters but will then fail with the error message `az group delete : Long running operation failed with status 'Conflict'.`. Run the az group delete command a second time to remove any residual resources as well as the resource group.
32+
33+
```azurecli-interactive
34+
az group delete --name $resourceGroupName
35+
```
36+
37+
## Script explanation
38+
39+
This script uses the following commands. Each command in the table links to command specific documentation.
40+
41+
| Command | Notes |
42+
|---|---|
43+
| [az group create](/cli/azure/group#az-group-create) | Creates a resource group in which all resources are stored. |
44+
| [az network vnet create](/cli/azure/network/vnet#az-network-vnet-create) | Creates a virtual network. |
45+
| [az network vnet subnet create](/cli/azure/network/vnet/subnet#az-network-vnet-subnet-create) | Adds a subnet configuration to a virtual network. |
46+
| [az network vnet show](/cli/azure/network/vnet#az-network-vnet-show) | Gets a virtual network in a resource group. |
47+
| [az network vnet subnet show](/cli/azure/network/vnet/subnet#az-network-vnet-subnet-show) | Gets a subnet in a virtual network. |
48+
| [az network nsg create](/cli/azure/network/nsg#az-network-nsg-create) | Creates a network security group. |
49+
| [az network route-table create](/cli/azure/network/route-table#az-network-route-table-create) | Creates a route table. |
50+
| [az network vnet subnet update](/cli/azure/network/vnet/subnet#az-network-vnet-subnet-update) | Updates a subnet configuration for a virtual network. |
51+
| [az network vnet update](/cli/azure/network/vnet#az-network-vnet-update) | Updates a virtual network. |
52+
| [az network nsg show](/cli/azure/network/nsg#az-network-nsg-show) | Gets a network security group. |
53+
| [az network nsg rule create](/cli/azure/network/nsg/rule#az-network-nsg-rule-create)| Adds a network security rule configuration to a network security group. |
54+
| [az network nsg rule update](/cli/azure/network/nsg#az-network-nsg-update) | Updates a network security group. |
55+
| [az network route-table route create](/cli/azure/network/route-table/route#az-network-route-table-route-create) | Adds a route to a route table. |
56+
| [az network route-table update](/cli/azure/network/route-table#az-network-route-table-update) | Updates a route table. |
57+
| [az sql mi create](/cli/azure/sql/mi#az-sql-mi-create) | Creates an Azure SQL Database managed instance. |
58+
| [az sql mi show](/cli/azure/sql/mi#az-sql-mi-show)| Returns information about Azure SQL Managed Database Instance. |
59+
| [az network public-ip create](/cli/azure/network/public-ip#az-network-public-ip-create) | Creates a public IP address. |
60+
| [az network vnet-gateway create](/cli/azure/network/vnet-gateway#az-network-vnet-gateway-create) | Creates a Virtual Network Gateway |
61+
| [az sql instance-failover-group create](/cli/azure/sql/instance-failover-group#az-sql-instance-failover-group-create) | Creates a new Azure SQL Database managed instance failover group. |
62+
| [az sql instance-failover-group show](/cli/azure/sql/instance-failover-group#az-sql-instance-failover-group-show) | Gets or lists managed instance failover groups.|
63+
| [az sql instance-failover-group set-primary](/cli/azure/sql/instance-failover-group#az-sql-instance-failover-group-set-primary) | Executes a failover of a managed instance failover group. |
64+
| [az group delete](/cli/azure/vm/extension#az-vm-extension-set) | Deletes a resource group including all nested resources. |
65+
66+
## Next steps
67+
68+
For more information on the Azure CLI, see [Azure CLI documentation](https://docs.microsoft.com/cli/azure).
69+
70+
Additional SQL Database CLI script samples can be found in the [Azure SQL Database documentation](../sql-database-cli-samples.md).

articles/sql-database/scripts/sql-database-add-single-db-to-failover-group-cli.md

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,32 @@ ms.date: 07/16/2019
1414
---
1515
# Use CLI to add an Azure SQL Database single database into a failover group
1616

17-
This PowerShell script example creates a single database, creates a failover group, adds the database to it, and tests failover.
17+
This Azure CLI script example creates a single database, creates a failover group, adds the database to it, and tests failover.
18+
19+
If you choose to install and use the CLI locally, this topic requires that you are running the Azure CLI version 2.0 or later. Run `az --version` to find the version. If you need to install or upgrade, see [Install the Azure CLI]( /cli/azure/install-azure-cli).
20+
21+
## Sample script
1822

1923
[!INCLUDE [quickstarts-free-trial-note](../../../includes/quickstarts-free-trial-note.md)]
2024

21-
[!INCLUDE [cloud-shell-try-it.md](../../../includes/cloud-shell-try-it.md)]
25+
### Sign in to Azure
2226

23-
If you choose to install and use the CLI locally, this topic requires that you are running the Azure CLI version 2.0 or later. Run `az --version` to find the version. If you need to install or upgrade, see [Install the Azure CLI]( /cli/azure/install-azure-cli).
27+
```azurecli-interactive
28+
$subscription = "<subscriptionId>" # add subscription here
2429
25-
## Sample script
30+
az account set -s $subscription # ...or use 'az login'
31+
```
32+
33+
### Run the script
2634

2735
[!code-azurecli-interactive[main](../../../cli_scripts/sql-database/failover-groups/add-single-db-to-failover-group-az-cli.sh "Add single database to failover group")]
2836

29-
## Clean up deployment
37+
### Clean up deployment
3038

31-
Use the following command to remove the resource group and all resources associated with it.
39+
Use the following command to remove the resource group and all resources associated with it.
3240

3341
```azurecli-interactive
34-
az group delete --name $resourceGroupName
42+
az group delete --name $resource
3543
```
3644

3745
## Script explanation
@@ -40,18 +48,11 @@ This script uses the following commands. Each command in the table links to comm
4048

4149
| Command | Notes |
4250
|---|---|
43-
| [az account set](/cli/azure/account?view=azure-cli-latest#az-account-set) | Sets a subscription to be the current active subscription. |
44-
| [az group create](/cli/azure/group#az-group-create) | Creates a resource group in which all resources are stored. |
45-
| [az sql server create](/cli/azure/sql/server#az-sql-server-create) | Creates a SQL Database server that hosts single databases and elastic pools. |
46-
| [az sql server firewall-rule create](/cli/azure/sql/server/firewall-rule) | Creates a server's firewall rules. |
47-
| [az sql db create](/cli/azure/sql/db?view=azure-cli-latest) | Creates a database. |
48-
| [az sql failover-group create](/cli/azure/sql/failover-group?view=azure-cli-latest#az-sql-failover-group-create) | Creates a failover group. |
49-
| [az sql failover-group list](/cli/azure/sql/failover-group?view=azure-cli-latest#az-sql-failover-group-list) | Lists the failover groups in a server. |
50-
| [az sql failover-group set-primary](/cli/azure/sql/failover-group?view=azure-cli-latest#az-sql-failover-group-set-primary) | Set the primary of the failover group by failing over all databases from the current primary server. |
51-
| [az group delete](https://docs.microsoft.com/cli/azure/vm/extension#az-vm-extension-set) | Deletes a resource group including all nested resources. |
51+
| [az sql db](/cli/azure/sql/db) | Creates a database. |
52+
| [az sql failover-group](/cli/azure/sql/failover-group) | Creates a failover group. |
5253

5354
## Next steps
5455

55-
For more information on the Azure CLI, see [Azure CLI documentation](https://docs.microsoft.com/cli/azure).
56+
For more information on the Azure CLI, see [Azure CLI documentation](/cli/azure).
5657

5758
Additional SQL Database CLI script samples can be found in the [Azure SQL Database documentation](../sql-database-cli-samples.md).
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
title: CLI example of auditing and Advanced Threat Protection - Azure SQL Database
3+
description: Azure CLI example script to configure auditing and Advanced Threat Protection in an Azure SQL Database
4+
services: sql-database
5+
ms.service: sql-database
6+
ms.subservice: security
7+
ms.custom: security
8+
ms.devlang: azurecli
9+
ms.topic: sample
10+
author: ronitr
11+
ms.author: ronitr
12+
ms.reviewer: carlrab, vanto
13+
ms.date: 08/05/2019
14+
---
15+
# Use CLI to configure SQL Database auditing and Advanced Threat Protection
16+
17+
This Azure CLI script example configures SQL Database auditing and Advanced Threat Protection.
18+
19+
If you choose to install and use the CLI locally, this topic requires that you are running the Azure CLI version 2.0 or later. Run `az --version` to find the version. If you need to install or upgrade, see [Install the Azure CLI](/cli/azure/install-azure-cli).
20+
21+
## Sample script
22+
23+
[!INCLUDE [quickstarts-free-trial-note](../../../includes/quickstarts-free-trial-note.md)]
24+
25+
### Sign in to Azure
26+
27+
```azurecli-interactive
28+
$subscription = "<subscriptionId>" # add subscription here
29+
30+
az account set -s $subscription # ...or use 'az login'
31+
```
32+
33+
### Run the script
34+
35+
[!code-azurecli-interactive[main](../../../cli_scripts/sql-database/database-auditing-and-threat-detection/database-auditing-and-threat-detection.sh "Configure auditing and threat detection")]
36+
37+
### Clean up deployment
38+
39+
Use the following command to remove the resource group and all resources associated with it.
40+
41+
```azurecli-interactive
42+
az group delete --name $resourceGroup
43+
```
44+
45+
## Script explanation
46+
47+
This script uses the following commands. Each command in the table links to command specific documentation.
48+
49+
| Command | Notes |
50+
|---|---|
51+
| [az sql db audit-policy](/cli/azure/sql/db/audit-policy) | Sets the auditing policy for a database. |
52+
| [az sql db threat-policy](/cli/azure/sql/db/threat-policy) | Sets an Advanced Threat Protection policy on a database. |
53+
54+
## Next steps
55+
56+
For more information on the Azure CLI, see [Azure CLI documentation](/cli/azure).
57+
58+
Additional SQL Database CLI script samples can be found in the [Azure SQL Database documentation](../sql-database-cli-samples.md).
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
title: CLI example-backup-Azure SQL database
3+
description: Azure CLI example script to backup an Azure SQL single database to an Azure storage container
4+
services: sql-database
5+
ms.service: sql-database
6+
ms.custom:
7+
ms.devlang: azurecli
8+
ms.topic: sample
9+
author: mashamsft
10+
ms.author: mathoma
11+
ms.reviewer: carlrab
12+
ms.date: 03/27/2019
13+
---
14+
# Use CLI to backup an Azure SQL single database to an Azure storage container
15+
16+
This Azure CLI example backs up an Azure SQL database to an Azure storage container.
17+
18+
If you choose to install and use the CLI locally, this article requires that you are running the Azure CLI version 2.0 or later. Run `az --version` to find the version. If you need to install or upgrade, see [Install the Azure CLI]( /cli/azure/install-azure-cli).
19+
20+
## Sample script
21+
22+
[!INCLUDE [quickstarts-free-trial-note](../../../includes/quickstarts-free-trial-note.md)]
23+
24+
### Sign in to Azure
25+
26+
```azurecli-interactive
27+
$subscription = "<subscriptionId>" # add subscription here
28+
29+
az account set -s $subscription # ...or use 'az login'
30+
```
31+
32+
### Run the script
33+
34+
[!code-azurecli-interactive[main](../../../cli_scripts/sql-database/backup-database/backup-database.sh "Restore SQL Database")]
35+
36+
### Clean up deployment
37+
38+
Use the following command to remove the resource group and all resources associated with it.
39+
40+
```azurecli-interactive
41+
az group delete --name $resourceGroup
42+
```
43+
44+
## Script explanation
45+
46+
This script uses the following commands. Each command in the table links to command specific documentation.
47+
48+
| Command | Notes |
49+
|---|---|
50+
| [az group create](/cli/azure/group#az-group-create) | Creates a resource group in which all resources are stored. |
51+
| [az sql server create](/cli/azure/sql/server#az-sql-server-create) | Creates a SQL Database server that hosts single databases and elastic pools. |
52+
| [az sql db show](/cli/azure/sql/db#az-sql-db-show) | Gets a SQL standalone or pooled database. |
53+
| [az sql db restore](/cli/azure/sql/db#az-sql-db-restore) | Restores a SQL standalone or pooled database. |
54+
| [az sql db delete](/cli/azure/sql/db#az-sql-db-delete) | Removes an Azure SQL standalone or pooled database. |
55+
| [az group delete](/cli/azure/vm/extension#az-vm-extension-set) | Deletes a resource group including all nested resources. |
56+
57+
## Next steps
58+
59+
For more information on the Azure CLI, see [Azure CLI documentation](/cli/azure).
60+
61+
Additional SQL Database CLI script samples can be found in the [Azure SQL Database documentation](../sql-database-cli-samples.md).
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
title: CLI example-copy-Azure SQL database-new server
3+
description: Azure CLI example script to copy a SQL database to a new server
4+
services: sql-database
5+
ms.service: sql-database
6+
ms.subservice: data-movement
7+
ms.custom:
8+
ms.devlang: azurecli
9+
ms.topic: sample
10+
author: stevestein
11+
ms.author: sstein
12+
ms.reviewer: carlrab
13+
ms.date: 03/12/2019
14+
---
15+
# Use CLI to copy a SQL database to a new server
16+
17+
This Azure CLI script example creates a copy of an existing database in a new server.
18+
19+
If you choose to install and use the CLI locally, this article requires that you are running the Azure CLI version 2.0 or later. Run `az --version` to find the version. If you need to install or upgrade, see [Install the Azure CLI](/cli/azure/install-azure-cli).
20+
21+
## Sample script
22+
23+
[!INCLUDE [quickstarts-free-trial-note](../../../includes/quickstarts-free-trial-note.md)]
24+
25+
### Sign in to Azure
26+
27+
```azurecli-interactive
28+
$subscription = "<subscriptionId>" # add subscription here
29+
30+
az account set -s $subscription # ...or use 'az login'
31+
```
32+
33+
### Run the script
34+
35+
[!code-azurecli-interactive[main](../../../cli_scripts/sql-database/copy-database-to-new-server/copy-database-to-new-server.sh "Copy database to new server")]
36+
37+
### Clean up deployment
38+
39+
Use the following command to remove the resource group and all resources associated with it.
40+
41+
```azurecli-interactive
42+
az group delete --name $sourceresourcegroupname
43+
az group delete --name $targetresourcegroupname
44+
```
45+
46+
## Script explanation
47+
48+
This script uses the following commands. Each command in the table links to command specific documentation.
49+
50+
| Command | Notes |
51+
|---|---|
52+
| [az sql db copy](/cli/azure/sql/db#az-sql-db-copy) | Creates a copy of a database that uses the snapshot at the current time. |
53+
54+
## Next steps
55+
56+
For more information on the Azure CLI, see [Azure CLI documentation](/cli/azure).
57+
58+
Additional SQL Database CLI script samples can be found in the [Azure SQL Database documentation](../sql-database-cli-samples.md).

0 commit comments

Comments
 (0)