Skip to content

Commit 7129ebb

Browse files
NewImplementation
1 parent d50aee3 commit 7129ebb

File tree

4 files changed

+61
-5
lines changed

4 files changed

+61
-5
lines changed

azure_custom.yaml

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json
2-
name: byoc-research-assistant
2+
name: byoc-research-assistant-custom
33

44
requiredVersions:
55
azd: ">= 1.18.0"
66

77
metadata:
8-
8+
9+
10+
infra:
11+
provider: bicep
12+
path: infra
13+
module: main
914

1015
services:
1116
webapp:
@@ -25,6 +30,55 @@ services:
2530
run: bash ../infra/scripts/package_webapp.sh
2631
interactive: true
2732
continueOnError: false
33+
postdeploy:
34+
windows:
35+
shell: pwsh
36+
run: |
37+
Write-Host ""
38+
Write-Host "🔄 Configuring App Service for code deployment..."
39+
$rgName = (azd env get-value AZURE_RESOURCE_GROUP)
40+
if ($rgName) {
41+
$appName = (az webapp list --resource-group $rgName --query "[?kind=='app,linux'].name" -o tsv)
42+
if ($appName) {
43+
Write-Host " Found App Service: $appName in $rgName"
44+
Write-Host " Setting Python 3.11 runtime and startup command..."
45+
az webapp config set --resource-group $rgName --name $appName --linux-fx-version `"PYTHON`|3.11`" --startup-file "gunicorn --bind=0.0.0.0:8000 --timeout 600 app:app" --output none
46+
Write-Host " Restarting App Service..."
47+
az webapp restart --resource-group $rgName --name $appName --output none
48+
Write-Host " ✅ App Service configured and restarted"
49+
} else {
50+
Write-Host " ⚠️ Could not find App Service"
51+
}
52+
} else {
53+
Write-Host " ⚠️ Could not determine resource group"
54+
}
55+
Write-Host ""
56+
interactive: true
57+
continueOnError: true
58+
posix:
59+
shell: sh
60+
run: |
61+
echo ""
62+
echo "🔄 Configuring App Service for code deployment..."
63+
RG_NAME=$(azd env get-value AZURE_RESOURCE_GROUP)
64+
if [ ! -z "$RG_NAME" ]; then
65+
APP_NAME=$(az webapp list --resource-group "$RG_NAME" --query "[?kind=='app,linux'].name" -o tsv)
66+
if [ ! -z "$APP_NAME" ]; then
67+
echo " Found App Service: $APP_NAME in $RG_NAME"
68+
echo " Setting Python 3.11 runtime and startup command..."
69+
az webapp config set --resource-group "$RG_NAME" --name "$APP_NAME" --linux-fx-version "PYTHON|3.11" --startup-file "gunicorn --bind=0.0.0.0:8000 --timeout 600 app:app" --output none
70+
echo " Restarting App Service..."
71+
az webapp restart --resource-group "$RG_NAME" --name "$APP_NAME" --output none
72+
echo " ✅ App Service configured and restarted"
73+
else
74+
echo " ⚠️ Could not find App Service"
75+
fi
76+
else
77+
echo " ⚠️ Could not determine resource group"
78+
fi
79+
echo ""
80+
interactive: true
81+
continueOnError: true
2882

2983
hooks:
3084
postprovision:

infra/main_custom.bicep

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,7 @@ module webSite 'modules/web-sites.bicep' = {
10411041
userAssignedIdentity.outputs.resourceId
10421042
]
10431043
}
1044-
tags: tags
1044+
tags: union(tags, { 'azd-service-name': 'webapp' })
10451045
location: location
10461046
kind: 'app,linux,container'
10471047
serverFarmResourceId: webServerFarm.?outputs.resourceId

infra/scripts/package_webapp.ps1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ Write-Host "`nStep 2: Copying backend files..."
6363
# Copy Python files and backend code
6464
$filesToCopy = @(
6565
"app.py",
66-
"requirements.txt"
66+
"requirements.txt",
67+
"start.sh",
68+
"start.cmd"
6769
)
6870

6971
foreach ($file in $filesToCopy) {

infra/scripts/package_webapp.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ echo ""
4949
echo "Step 2: Copying backend files..."
5050

5151
# Copy Python files and backend code
52-
for file in app.py requirements.txt; do
52+
for file in app.py requirements.txt start.sh start.cmd; do
5353
if [ -f "$SRC_DIR/$file" ]; then
5454
echo " Copying $file"
5555
cp "$SRC_DIR/$file" "$DIST_DIR/"

0 commit comments

Comments
 (0)