Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9307dca

Browse files
committed
Merge branch 'v2.0' into v3.0
2 parents 49d4354 + 1b3d17c commit 9307dca

File tree

4 files changed

+114
-61
lines changed

4 files changed

+114
-61
lines changed

‎database/azure-create-sql-db.sh

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,18 @@ else
1212
exit 1
1313
fi
1414

15-
echo "Creating Resource Group...";
16-
az group create \
17-
-n $resourceGroup \
18-
-l $location
19-
2015
echo "Deploying Azure SQL Database...";
21-
pwd1=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 6 ; echo`
22-
pwd2=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 6 ; echo`
23-
adminPwd="${pwd1}_${pwd2}"
24-
adminName="db_admin"
2516
azureSQLDB="todo_v3"
17+
azureSQLSRV=`az sql server list -g $resourceGroup --query '[0].name' -o tsv`
18+
echo "(Server: '$azureSQLSRV', Location: '$location', Resource Group: '$resourceGroup')"
2619
azureSQLServer=$(az deployment group create \
2720
--name "sql-db-deploy-3.0" \
2821
--resource-group $resourceGroup \
2922
--template-file azure-sql-db.arm.json \
3023
--parameters \
24+
databaseServer=$azureSQLSRV \
3125
databaseName=$azureSQLDB \
3226
location=$location \
33-
databaseAdministratorLogin=$adminName \
34-
databaseAdministratorLoginPassword=$adminPwd \
3527
--query properties.outputs.databaseServer.value \
3628
-o tsv \
3729
)
@@ -40,6 +32,4 @@ echo "Azure SQL Database available at";
4032
echo "- Location: $location"
4133
echo "- Server: $azureSQLServer"
4234
echo "- Database: $azureSQLDB"
43-
echo "- Admin Login: $adminName"
44-
echo "- Admin Password: $adminPwd"
4535
echo "Done."

‎database/azure-create-sql-srv.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
# Load values from .env file
5+
FILE="../.env"
6+
if [[ -f $FILE ]]; then
7+
echo "Loading from $FILE"
8+
eval $(egrep "^[^#;]" $FILE | tr '\n' '0円' | xargs -0 -n1 | sed 's/^/export /')
9+
else
10+
echo "Enviroment file not detected."
11+
echo "Please make sure there is a .env file in the sample root folder and run the script again."
12+
exit 1
13+
fi
14+
15+
echo "Creating Resource Group...";
16+
az group create \
17+
-n $resourceGroup \
18+
-l $location
19+
20+
echo "Deploying Azure SQL Logical Server...";
21+
pwd1=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 6 ; echo`
22+
pwd2=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 6 ; echo`
23+
adminPwd="${pwd1}_${pwd2}"
24+
adminName="db_admin"
25+
azureSQLDB="todo_v2"
26+
azureSQLServer=$(az deployment group create \
27+
--name "sql-srv-deploy-2.0" \
28+
--resource-group $resourceGroup \
29+
--template-file azure-sql-srv.arm.json \
30+
--parameters \
31+
location=$location \
32+
databaseAdministratorLogin=$adminName \
33+
databaseAdministratorLoginPassword=$adminPwd \
34+
--query properties.outputs.databaseServer.value \
35+
-o tsv \
36+
)
37+
38+
echo "Azure SQL Database available at";
39+
echo "- Location: $location"
40+
echo "- Server: $azureSQLServer"
41+
echo "- Admin Login: $adminName"
42+
echo "- Admin Password: $adminPwd"
43+
echo "Done."

‎database/azure-sql-db.arm.json

Lines changed: 3 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
},
88
"databaseServer": {
99
"type": "string",
10-
"defaultValue": "[uniqueString(resourceGroup().id)]",
1110
"metadata": {
1211
"description": "Azure SQL Database server"
1312
}
@@ -17,65 +16,21 @@
1716
"metadata": {
1817
"description": "Azure SQL Database name"
1918
}
20-
},
21-
"databaseAdministratorLogin": {
22-
"type": "string",
23-
"defaultValue": "db_admin",
24-
"metadata": {
25-
"description": "Azure SQL Database admin user name"
26-
}
27-
},
28-
"databaseAdministratorLoginPassword": {
29-
"type": "securestring",
30-
"defaultValue": "AzUR3SqL_PAzzw0rd!",
31-
"metadata": {
32-
"description": "Azure SQL Database admin password"
33-
}
34-
}
19+
}
3520
},
36-
"resources": [
37-
{
38-
"type": "Microsoft.Sql/servers",
39-
"apiVersion": "2021年02月01日-preview",
40-
"name": "[parameters('databaseServer')]",
41-
"location": "[parameters('location')]",
42-
"kind": "v12.0",
43-
"properties": {
44-
"administratorLogin": "[parameters('databaseAdministratorLogin')]",
45-
"administratorLoginPassword": "[parameters('databaseAdministratorLoginPassword')]",
46-
"version": "12.0",
47-
"minimalTlsVersion": "1.2",
48-
"publicNetworkAccess": "Enabled",
49-
"restrictOutboundNetworkAccess": "Disabled"
50-
}
51-
},
21+
"resources": [
5222
{
5323
"type": "Microsoft.Sql/servers/databases",
5424
"apiVersion": "2021年02月01日-preview",
5525
"name": "[concat(parameters('databaseServer'), '/', parameters('databaseName'))]",
56-
"location": "[parameters('location')]",
57-
"dependsOn": [
58-
"[resourceId('Microsoft.Sql/servers', parameters('databaseServer'))]"
59-
],
26+
"location": "[parameters('location')]",
6027
"sku": {
6128
"name": "GP_Gen5",
6229
"capacity": 2
6330
},
6431
"properties":{
6532
"highAvailabilityReplicaCount": 0
6633
}
67-
},
68-
{
69-
"type": "Microsoft.Sql/servers/firewallRules",
70-
"apiVersion": "2021年02月01日-preview",
71-
"name": "[concat(parameters('databaseServer'), '/AllowAllWindowsAzureIps')]",
72-
"dependsOn": [
73-
"[resourceId('Microsoft.Sql/servers', parameters('databaseServer'))]"
74-
],
75-
"properties": {
76-
"startIpAddress": "0.0.0.0",
77-
"endIpAddress": "0.0.0.0"
78-
}
7934
}
8035
],
8136
"outputs": {

‎database/azure-sql-srv.arm.json

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
3+
"contentVersion": "1.0.0.0",
4+
"parameters": {
5+
"location": {
6+
"type": "string"
7+
},
8+
"databaseServer": {
9+
"type": "string",
10+
"defaultValue": "[uniqueString(resourceGroup().id)]",
11+
"metadata": {
12+
"description": "Azure SQL Database server"
13+
}
14+
},
15+
"databaseAdministratorLogin": {
16+
"type": "string",
17+
"defaultValue": "db_admin",
18+
"metadata": {
19+
"description": "Azure SQL Database admin user name"
20+
}
21+
},
22+
"databaseAdministratorLoginPassword": {
23+
"type": "securestring",
24+
"defaultValue": "AzUR3SqL_PAzzw0rd!",
25+
"metadata": {
26+
"description": "Azure SQL Database admin password"
27+
}
28+
}
29+
},
30+
"resources": [
31+
{
32+
"type": "Microsoft.Sql/servers",
33+
"apiVersion": "2021年02月01日-preview",
34+
"name": "[parameters('databaseServer')]",
35+
"location": "[parameters('location')]",
36+
"kind": "v12.0",
37+
"properties": {
38+
"administratorLogin": "[parameters('databaseAdministratorLogin')]",
39+
"administratorLoginPassword": "[parameters('databaseAdministratorLoginPassword')]",
40+
"version": "12.0",
41+
"minimalTlsVersion": "1.2",
42+
"publicNetworkAccess": "Enabled",
43+
"restrictOutboundNetworkAccess": "Disabled"
44+
}
45+
},
46+
{
47+
"type": "Microsoft.Sql/servers/firewallRules",
48+
"apiVersion": "2021年02月01日-preview",
49+
"name": "[concat(parameters('databaseServer'), '/AllowAllWindowsAzureIps')]",
50+
"dependsOn": [
51+
"[resourceId('Microsoft.Sql/servers', parameters('databaseServer'))]"
52+
],
53+
"properties": {
54+
"startIpAddress": "0.0.0.0",
55+
"endIpAddress": "0.0.0.0"
56+
}
57+
}
58+
],
59+
"outputs": {
60+
"databaseServer": {
61+
"type": "string",
62+
"value": "[parameters('databaseServer')]"
63+
}
64+
}
65+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /