-
Notifications
You must be signed in to change notification settings - Fork 65
71 lines (62 loc) · 2.43 KB
/
sql_load-your-mssql-database-with-data_README_md.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
on:
schedule:
- cron: '0 5 * * 1'
workflow_dispatch:
name: 'sql/load-your-mssql-database-with-data/README.md'
jobs:
validate:
runs-on: 'ubuntu-latest'
steps:
- uses: 'azure/login@v1'
with:
subscription-id: '${{ secrets.AZURE_SUBSCRIPTION_ID }}'
client-id: '${{ secrets.AZURE_CLIENT_ID }}'
tenant-id: '${{ secrets.AZURE_TENANT_ID }}'
- uses: 'actions/checkout@v3'
- run: |
if [[ -z $REGION ]]; then
export REGION=westus2
fi
if [[ -z $REGION ]]; then
export REGION=westus
fi
if [[ -z $RESOURCE_GROUP ]]; then
export RESOURCE_GROUP=joazrg-$RANDOM
echo "Using '"$RESOURCE_GROUP"' as resource group"
fi
az group create --name $RESOURCE_GROUP --location $REGION
if [[ -z $MSSQL_NAME ]]; then
export MSSQL_NAME=mssql-$RANDOM
export MSSQL_USERNAME=mssql
export MSSQL_PASSWORD=p#ssw0rd-$RANDOM
fi
az sql server create \
--admin-user $MSSQL_USERNAME \
--admin-password $MSSQL_PASSWORD \
--name $MSSQL_NAME \
--resource-group $RESOURCE_GROUP
export LOCAL_IP=`curl -s whatismyip.akamai.com`
az sql server firewall-rule create \
--resource-group $RESOURCE_GROUP \
--server $MSSQL_NAME \
--name AllowMyLocalIP \
--start-ip-address $LOCAL_IP \
--end-ip-address $LOCAL_IP
cd sql/load-your-mssql-database-with-data
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 1
python -m pip install --upgrade pip
sudo pip install mssql-cli
sudo pip install cli-helpers --upgrade --force
export MSSQL_DNS_NAME=`az sql server show \
--resource-group $RESOURCE_GROUP \
--name $MSSQL_NAME \
--query fullyQualifiedDomainName \
--output tsv`
export MSSQL_CLIENT_USERNAME="$MSSQL_USERNAME@$MSSQL_NAME"
mssql-cli -S $MSSQL_DNS_NAME -U $MSSQL_CLIENT_USERNAME -P $MSSQL_PASSWORD -i create.sql
mssql-cli -S $MSSQL_DNS_NAME -U $MSSQL_CLIENT_USERNAME -P $MSSQL_PASSWORD -d demo -i load.sql
cd ../..
az group delete --name $RESOURCE_GROUP --yes || true
permissions:
contents: 'read'
id-token: 'write'