-
Notifications
You must be signed in to change notification settings - Fork 628
Expand file tree
/
Copy pathrun_create_table_script.sh
More file actions
43 lines (33 loc) · 1.62 KB
/
run_create_table_script.sh
File metadata and controls
43 lines (33 loc) · 1.62 KB
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
#!/bin/bash
echo "started the script"
# Variables
baseUrl="$1"
# keyvaultName="$2"
requirementFile="requirements.txt"
requirementFileUrl=${baseUrl}"scripts/data_scripts/requirements.txt"
resourceGroup="$2"
serverName="$3"
webAppPrincipalName="$4"
adminAppPrincipalName="$5"
functionAppPrincipalName="$6"
managedIdentityName="$7"
echo "Script Started"
# Get the public IP address of the machine running the script
publicIp=$(curl -s https://api.ipify.org)
# Use Azure CLI to add the public IP to the PostgreSQL firewall rule
az postgres flexible-server firewall-rule create --resource-group $resourceGroup --name $serverName --rule-name "AllowScriptIp" --start-ip-address "$publicIp" --end-ip-address "$publicIp"
# Download the create table python file
curl --output "create_postgres_tables.py" ${baseUrl}"scripts/data_scripts/create_postgres_tables.py"
curl --output "azure_credential_utils.py" ${baseUrl}"scripts/data_scripts/azure_credential_utils.py"
# Download the requirement file
curl --output "$requirementFile" "$requirementFileUrl"
echo "Download completed"
#Replace key vault name
# sed -i "s/kv_to-be-replaced/${keyvaultName}/g" "create_postgres_tables.py"
sed -i "s/webAppPrincipalName/${webAppPrincipalName}/g" "create_postgres_tables.py"
sed -i "s/adminAppPrincipalName/${adminAppPrincipalName}/g" "create_postgres_tables.py"
sed -i "s/managedIdentityName/${managedIdentityName}/g" "create_postgres_tables.py"
sed -i "s/functionAppPrincipalName/${functionAppPrincipalName}/g" "create_postgres_tables.py"
sed -i "s/serverName/${serverName}/g" "create_postgres_tables.py"
pip install -r requirements.txt
python create_postgres_tables.py