Skip to content

Commit a17abb4

Browse files
committed
Fix Azure deployment: update startup script and add startup command to Bicep
1 parent 8a98b34 commit a17abb4

2 files changed

Lines changed: 7 additions & 20 deletions

File tree

infra/main.bicep

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,12 @@ var appServicePlanName = 'az-${resourcePrefix}-plan-${resourceToken}'
2525
// App Service name
2626
var appServiceName = 'az-${resourcePrefix}-app-${resourceToken}'
2727

28-
// User-assigned managed identity name
29-
var managedIdentityName = 'az-${resourcePrefix}-mi-${resourceToken}'
30-
31-
// Create User-assigned Managed Identity
32-
resource managedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = {
33-
name: managedIdentityName
34-
location: location
35-
tags: {
36-
'azd-env-name': environmentName
37-
'azd-service-name': 'todo-app'
38-
}
39-
}
40-
4128
// Create App Service Plan (P0V3 Linux)
4229
resource appServicePlan 'Microsoft.Web/serverfarms@2024-04-01' = {
4330
name: appServicePlanName
4431
location: location
4532
tags: {
4633
'azd-env-name': environmentName
47-
'azd-service-name': 'todo-app'
4834
}
4935
sku: {
5036
name: 'P0v3'
@@ -68,17 +54,15 @@ resource appService 'Microsoft.Web/sites@2024-04-01' = {
6854
'azd-service-name': 'todo-app'
6955
}
7056
identity: {
71-
type: 'UserAssigned'
72-
userAssignedIdentities: {
73-
'${managedIdentity.id}': {}
74-
}
57+
type: 'SystemAssigned'
7558
}
7659
properties: {
7760
serverFarmId: appServicePlan.id
7861
reserved: true
7962
httpsOnly: true
8063
siteConfig: {
8164
linuxFxVersion: 'PYTHON|3.12'
65+
appCommandLine: 'bash startup.sh'
8266
appSettings: [
8367
{
8468
name: 'SECRET_KEY'
@@ -110,6 +94,6 @@ resource appService 'Microsoft.Web/sites@2024-04-01' = {
11094
// Outputs
11195
output RESOURCE_GROUP_ID string = resourceGroup().id
11296
output AZURE_LOCATION string = location
113-
output SERVICE_TODO_APP_IDENTITY_PRINCIPAL_ID string = managedIdentity.properties.principalId
97+
output SERVICE_TODO_APP_IDENTITY_PRINCIPAL_ID string = appService.identity.principalId
11498
output SERVICE_TODO_APP_NAME string = appService.name
11599
output SERVICE_TODO_APP_URI string = 'https://${appService.properties.defaultHostName}'

startup.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ pip install -r requirements.txt
55

66
# Initialize the database
77
python -c "
8+
import sys
9+
import os
10+
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
811
from src.app import create_app
912
from src.models import db
1013
@@ -15,4 +18,4 @@ with app.app_context():
1518
"
1619

1720
# Start the application
18-
exec gunicorn --bind=0.0.0.0:$PORT --workers=2 --timeout=600 --keep-alive=2 --max-requests=1000 --max-requests-jitter=50 --preload src.app:app
21+
exec gunicorn --bind=0.0.0.0:$PORT --workers=2 --timeout=600 --keep-alive=2 --max-requests=1000 --max-requests-jitter=50 --preload main:app

0 commit comments

Comments
 (0)