forked from nlweb-ai/NLWeb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy_azure_webapp.sh
More file actions
executable file
·130 lines (117 loc) · 3.06 KB
/
deploy_azure_webapp.sh
File metadata and controls
executable file
·130 lines (117 loc) · 3.06 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
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/bin/bash
# Azure Web App deployment script
# Function to display usage
usage() {
echo "Usage: $0 --app-name <webapp-name> --resource-group <resource-group>"
echo ""
echo "Options:"
echo " -a, --app-name Azure Web App name (required)"
echo " -r, --resource-group Azure Resource Group name (required)"
echo " -h, --help Show this help message"
echo ""
echo "Example:"
echo " $0 --app-name myapp --resource-group MyResourceGroup"
echo " $0 -a myapp -r MyResourceGroup"
exit 1
}
# Parse command line arguments
WEBAPP_NAME=""
RESOURCE_GROUP=""
while [[ $# -gt 0 ]]; do
case $1 in
-a|--app-name)
WEBAPP_NAME="$2"
shift 2
;;
-r|--resource-group)
RESOURCE_GROUP="$2"
shift 2
;;
-h|--help)
usage
;;
*)
echo "Unknown option: $1"
usage
;;
esac
done
# Validate required arguments
if [ -z "$WEBAPP_NAME" ] || [ -z "$RESOURCE_GROUP" ]; then
echo "Error: Both --app-name and --resource-group are required."
echo ""
usage
fi
# Generate zip file name with app name and timestamp
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
ZIP_FILE="${WEBAPP_NAME}_deploy_${TIMESTAMP}.zip"
echo "========================================="
echo "Azure Web App Deployment Script"
echo "========================================="
# Remove old zip if exists
echo "Removing old deployment zip..."
rm -f $ZIP_FILE
# Create deployment zip
echo "Creating deployment zip file..."
zip -r $ZIP_FILE . \
-x "*.git*" \
-x "*.zip" \
-x "node_modules/*" \
-x "docs/*" \
-x "AskAgent/logs/*" \
-x "*__pycache__/*" \
-x "*.DS_Store*" \
-x "*json_with_embeddings/*" \
-x "*jsonl/*" \
-x "*htmlcov/*" \
-x "*.pyc" \
-x "*.pyo" \
-x "*.pyd" \
-x ".Python" \
-x "env/*" \
-x "venv/*" \
-x ".venv/*" \
-x "*.egg-info/*" \
-x "dist/*" \
-x "build/*" \
-x ".pytest_cache/*" \
-x ".mypy_cache/*" \
-x "Dockerfile*" \
-x "*.log" \
-x "create_*.sh" \
-x "deploy_*.sh" \
-x "install_*.sh" \
-x "*/mahi/*" \
-x "*.dedup.txt"
# Show zip file size
echo ""
echo "Deployment zip created: $ZIP_FILE"
ls -lh $ZIP_FILE
# Deploy to Azure
echo ""
echo "Deploying to Azure Web App..."
echo " Web App: $WEBAPP_NAME"
echo " Resource Group: $RESOURCE_GROUP"
echo " Zip File: $ZIP_FILE"
echo ""
az webapp deployment source config-zip \
--resource-group $RESOURCE_GROUP \
--name $WEBAPP_NAME \
--src $ZIP_FILE
if [ $? -eq 0 ]; then
echo ""
echo "========================================="
echo "Deployment Successful!"
echo "========================================="
echo "Web App URL: https://${WEBAPP_NAME}.azurewebsites.net"
echo ""
echo "To view logs:"
echo " az webapp log tail --name $WEBAPP_NAME --resource-group $RESOURCE_GROUP"
echo ""
echo "To test the /who endpoint:"
echo " curl 'https://${WEBAPP_NAME}.azurewebsites.net/who?query=test'"
else
echo ""
echo "Deployment failed. Check the error messages above."
exit 1
fi