Skip to content

Commit d1d73a6

Browse files
authored
Merge pull request #106043 from msebolt/patch-10
Update sql-database-create-single-database.md
2 parents 47e0422 + 8531d65 commit d1d73a6

File tree

2 files changed

+31
-124
lines changed

2 files changed

+31
-124
lines changed

articles/sql-database/includes/sql-database-create-single-database.md

Lines changed: 18 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -157,64 +157,30 @@ Create your resource group and single database using AZ CLI.
157157

158158
```azurecli-interactive
159159
#!/bin/bash
160-
# Set variables
161-
subscriptionID=<SubscriptionID>
162-
resourceGroupName=myResourceGroup-$RANDOM
163-
location=SouthCentralUS
164-
adminLogin=azureuser
165-
password="PWD27!"+`openssl rand -base64 18`
166-
serverName=mysqlserver-$RANDOM
167-
databaseName=mySampleDatabase
168-
drLocation=NorthEurope
169-
drServerName=mysqlsecondary-$RANDOM
170-
failoverGroupName=failovergrouptutorial-$RANDOM
171-
172-
# The ip address range that you want to allow to access your DB.
173-
# Leaving at 0.0.0.0 will prevent outside-of-azure connections to your DB
174-
startip=0.0.0.0
175-
endip=0.0.0.0
160+
# set variables
161+
$subscription = "<subscriptionID>"
162+
$randomIdentifier = $(Get-Random)
163+
164+
$resourceGroup = "resource-$randomIdentifier"
165+
$location = "East US"
166+
167+
$login = "sampleLogin"
168+
$password = "samplePassword123!"
169+
170+
$server = "server-$randomIdentifier"
171+
$database = "database-$randomIdentifier"
176172
177-
# Connect to Azure
178-
az login
179-
180-
# Set the subscription context for the Azure account
181-
az account set -s $subscriptionID
173+
az login # connect to Azure
174+
az account set -s $subscription # set subscription context for the Azure account
182175
183-
# Create a resource group
184176
echo "Creating resource group..."
185-
az group create \
186-
--name $resourceGroupName \
187-
--location $location \
188-
--tags Owner[=SQLDB-Samples]
177+
az group create --name $resourceGroup --location $location
189178
190-
# Create a logical server in the resource group
191179
echo "Creating primary logical server..."
192-
az sql server create \
193-
--name $serverName \
194-
--resource-group $resourceGroupName \
195-
--location $location \
196-
--admin-user $adminLogin \
197-
--admin-password $password
198-
199-
# Configure a firewall rule for the server
200-
echo "Configuring firewall..."
201-
az sql server firewall-rule create \
202-
--resource-group $resourceGroupName \
203-
--server $serverName \
204-
-n AllowYourIp \
205-
--start-ip-address $startip \
206-
--end-ip-address $endip
207-
208-
# Create a gen5 1vCore database in the server
180+
az sql server create --name $server --resource-group $resourceGroup --location $location --admin-user $login --admin-password $password
181+
209182
echo "Creating a gen5 2 vCore database..."
210-
az sql db create \
211-
--resource-group $resourceGroupName \
212-
--server $serverName \
213-
--name $databaseName \
214-
--sample-name AdventureWorksLT \
215-
--edition GeneralPurpose \
216-
--family Gen5 \
217-
--capacity 2
183+
az sql db create --resource-group $resourceGroup --server $server --name $database --sample-name AdventureWorksLT --edition GeneralPurpose --family Gen5 --capacity 2
218184
```
219185

220186
This script uses the following commands. Each command in the table links to command specific documentation.

articles/sql-database/sql-database-single-database-failover-group-tutorial.md

Lines changed: 13 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -168,45 +168,16 @@ Create your failover group and add your single database to it using AZ CLI.
168168
169169
```azurecli-interactive
170170
#!/bin/bash
171-
# Set variables
172-
# subscriptionID=<SubscriptionID>
173-
# resourceGroupName=myResourceGroup-$RANDOM
174-
# location=SouthCentralUS
175-
# adminLogin=azureuser
176-
# password="PWD27!"+`openssl rand -base64 18`
177-
# serverName=mysqlserver-$RANDOM
178-
# databaseName=mySampleDatabase
179-
drLocation=NorthEurope
180-
drServerName=mysqlsecondary-$RANDOM
181-
failoverGroupName=failovergrouptutorial-$RANDOM
171+
# set variables
172+
$failoverLocation = "West US"
173+
$failoverServer = "failoverServer-$randomIdentifier"
174+
$failoverGroup = "failoverGroup-$randomIdentifier"
182175
183-
# Create a secondary server in the failover region
184176
echo "Creating a secondary logical server in the DR region..."
185-
az sql server create \
186-
--name $drServerName \
187-
--resource-group $resourceGroupName \
188-
--location $drLocation \
189-
--admin-user $adminLogin\
190-
--admin-password $password
191-
192-
# Configure a firewall rule for the server
193-
echo "Configuring firewall..."
194-
az sql server firewall-rule create \
195-
--resource-group $resourceGroupName \
196-
--server $drServerName \
197-
-n AllowYourIp \
198-
--start-ip-address $startip \
199-
--end-ip-address $endip
177+
az sql server create --name $failoverServer --resource-group $resourceGroup --location $failoverLocation --admin-user $login --admin-password $password
200178
201-
# Create a failover group between the servers and add the database
202179
echo "Creating a failover group between the two servers..."
203-
az sql failover-group create \
204-
--name $failoverGroupName \
205-
--partner-server $drServerName \
206-
--resource-group $resourceGroupName \
207-
--server $serverName \
208-
--add-db $databaseName
209-
--failover-policy Automatic
180+
az sql failover-group create --name $failoverGroup --partner-server $failoverServer --resource-group $resourceGroup --server $server --add-db $database --failover-policy Automatic
210181
```
211182

212183
This portion of the tutorial uses the following Az CLI cmdlets:
@@ -314,48 +285,24 @@ Verify which server is the secondary:
314285

315286

316287
```azurecli-interactive
317-
# Set variables
318-
# resourceGroupName=myResourceGroup-$RANDOM
319-
# serverName=mysqlserver-$RANDOM
320-
321-
# Verify which server is secondary
322288
echo "Verifying which server is in the secondary role..."
323-
az sql failover-group list \
324-
--server $serverName \
325-
--resource-group $resourceGroupName
289+
az sql failover-group list --server $server --resource-group $resourceGroup
326290
```
327291

328292
Fail over to the secondary server:
329293

330294
```azurecli-interactive
331-
# Set variables
332-
# resourceGroupName=myResourceGroup-$RANDOM
333-
# drServerName=mysqlsecondary-$RANDOM
334-
# failoverGroupName=failovergrouptutorial-$RANDOM
335-
336-
337295
echo "Failing over group to the secondary server..."
338-
az sql failover-group set-primary \
339-
--name $failoverGroupName \
340-
--resource-group $resourceGroupName \
341-
--server $drServerName
342-
echo "Successfully failed failover group over to" $drServerName
296+
az sql failover-group set-primary --name $failoverGroup --resource-group $resourceGroup --server $failoverServer
297+
echo "Successfully failed failover group over to" $failoverServer
343298
```
344299

345300
Revert failover group back to the primary server:
346301

347302
```azurecli-interactive
348-
# Set variables
349-
# resourceGroupName=myResourceGroup-$RANDOM
350-
# serverName=mysqlserver-$RANDOM
351-
# failoverGroupName=failovergrouptutorial-$RANDOM
352-
353303
echo "Failing over group back to the primary server..."
354-
az sql failover-group set-primary \
355-
--name $failoverGroupName \
356-
--resource-group $resourceGroupName \
357-
--server $serverName
358-
echo "Successfully failed failover group back to" $serverName
304+
az sql failover-group set-primary --name $failoverGroup --resource-group $resourceGroup --server $server
305+
echo "Successfully failed failover group back to" $server
359306
```
360307

361308
This portion of the tutorial uses the following Az CLI cmdlets:
@@ -381,7 +328,6 @@ Delete the resource group using the Azure portal.
381328

382329
Delete the resource group using PowerShell.
383330

384-
385331
```powershell-interactive
386332
# Set variables
387333
# $resourceGroupName = "myResourceGroup-$(Get-Random)"
@@ -404,14 +350,9 @@ Delete the resource group by using AZ CLI.
404350

405351

406352
```azurecli-interactive
407-
# Set variables
408-
# resourceGroupName=myResourceGroup-$RANDOM
409-
410-
# Clean up resources by removing the resource group
411353
echo "Cleaning up resources by removing the resource group..."
412-
az group delete \
413-
--name $resourceGroupName
414-
echo "Successfully removed resource group" $resourceGroupName
354+
az group delete --name $resourceGroup
355+
echo "Successfully removed resource group" $resourceGroup
415356
```
416357

417358
This portion of the tutorial uses the following Az CLI cmdlets:

0 commit comments

Comments
 (0)