-
Notifications
You must be signed in to change notification settings - Fork 627
Expand file tree
/
Copy pathrun_create_table_script.sh
More file actions
35 lines (25 loc) · 1.22 KB
/
run_create_table_script.sh
File metadata and controls
35 lines (25 loc) · 1.22 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
#!/bin/bash
echo "started the script"
# Variables
baseUrl="$1"
requirementFile="requirements.txt"
requirementFileUrl=${baseUrl}"scripts/data_scripts/requirements.txt"
resourceGroup="$2"
serverName="$3"
managedIdentityName="$4"
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 placeholders in the python script with actual values
sed -i "s/managedIdentityName/${managedIdentityName}/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