Skip to content

Commit 456a897

Browse files
committed
restart container apps
1 parent 70a0a49 commit 456a897

1 file changed

Lines changed: 177 additions & 5 deletions

File tree

infra/main.bicep

Lines changed: 177 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,6 @@ module avmContainerRegistry 'modules/container-registry.bicep' = {
245245
}
246246
}
247247

248-
249-
250-
251248
// module containerRegistry 'deploy_container_registry.bicep' = {
252249
// name: 'deploy_container_registry'
253250
// params: {
@@ -665,7 +662,7 @@ module avmContainerApp 'br/public:avm/res/app/container-app:0.16.0' = {
665662
env: [
666663
{
667664
name: 'APP_CONFIG_ENDPOINT'
668-
value: avmAppConfig.outputs.endpoint
665+
value: ''
669666
}
670667
]
671668
}
@@ -716,7 +713,7 @@ module avmContainerApp_API 'br/public:avm/res/app/container-app:0.16.0' = {
716713
env: [
717714
{
718715
name: 'APP_CONFIG_ENDPOINT'
719-
value: avmAppConfig.outputs.endpoint
716+
value: ''
720717
}
721718
]
722719
probes: [
@@ -1147,6 +1144,181 @@ module avmRoleAssignment_container_app_web 'br/public:avm/ptn/authorization/reso
11471144
// dependsOn: [roleAssignments]
11481145
// }
11491146

1147+
module avmContainerApp_update 'br/public:avm/res/app/container-app:0.16.0' = {
1148+
name: format(deployment_param.resource_name_format_string, 'caapp-update-')
1149+
params: {
1150+
name: '${abbrs.containers.containerApp}${deployment_param.solution_prefix}-app'
1151+
location: deployment_param.resource_group_location
1152+
environmentResourceId: avmContainerAppEnv.outputs.resourceId
1153+
workloadProfileName: 'Consumption'
1154+
registries: deployment_param.use_local_build == 'localbuild'
1155+
? [
1156+
{
1157+
server: deployment_param.public_container_image_endpoint
1158+
identity: avmContainerRegistryReader.outputs.principalId
1159+
}
1160+
]
1161+
: null
1162+
1163+
managedIdentities: {
1164+
systemAssigned: true
1165+
userAssignedResourceIds: [
1166+
avmContainerRegistryReader.outputs.resourceId
1167+
]
1168+
}
1169+
1170+
containers: [
1171+
{
1172+
name: '${abbrs.containers.containerApp}${deployment_param.solution_prefix}'
1173+
image: '${deployment_param.public_container_image_endpoint}/contentprocessor:latest'
1174+
1175+
resources: {
1176+
cpu: '4'
1177+
memory: '8.0Gi'
1178+
}
1179+
env: [
1180+
{
1181+
name: 'APP_CONFIG_ENDPOINT'
1182+
value: avmAppConfig.outputs.endpoint
1183+
}
1184+
]
1185+
}
1186+
]
1187+
activeRevisionsMode: 'Single'
1188+
ingressExternal: false
1189+
disableIngress: true
1190+
scaleSettings: {
1191+
minReplicas: container_app_deployment.container_app.minReplicas
1192+
maxReplicas: container_app_deployment.container_app.maxReplicas
1193+
}
1194+
}
1195+
dependsOn: [
1196+
avmStorageAccount_RoleAssignment_avmContainerApp_blob
1197+
avmStorageAccount_RoleAssignment_avmContainerApp_queue
1198+
avmRoleAssignment_container_app
1199+
]
1200+
}
1201+
1202+
module avmContainerApp_API_update 'br/public:avm/res/app/container-app:0.16.0' = {
1203+
name: format(deployment_param.resource_name_format_string, 'caapi-update-')
1204+
params: {
1205+
name: '${abbrs.containers.containerApp}${deployment_param.solution_prefix}-api'
1206+
location: deployment_param.resource_group_location
1207+
environmentResourceId: avmContainerAppEnv.outputs.resourceId
1208+
workloadProfileName: 'Consumption'
1209+
registries: deployment_param.use_local_build == 'localbuild'
1210+
? [
1211+
{
1212+
server: deployment_param.public_container_image_endpoint
1213+
image: 'contentprocessorapi'
1214+
imageTag: 'latest'
1215+
}
1216+
]
1217+
: null
1218+
1219+
managedIdentities: {
1220+
systemAssigned: true
1221+
userAssignedResourceIds: [
1222+
avmContainerRegistryReader.outputs.resourceId
1223+
]
1224+
}
1225+
1226+
containers: [
1227+
{
1228+
name: '${abbrs.containers.containerApp}${deployment_param.solution_prefix}-api'
1229+
image: '${deployment_param.public_container_image_endpoint}/contentprocessorapi:latest'
1230+
resources: {
1231+
cpu: '4'
1232+
memory: '8.0Gi'
1233+
}
1234+
env: [
1235+
{
1236+
name: 'APP_CONFIG_ENDPOINT'
1237+
value: avmAppConfig.outputs.endpoint
1238+
}
1239+
]
1240+
probes: [
1241+
// Liveness Probe - Checks if the app is still running
1242+
{
1243+
type: 'Liveness'
1244+
httpGet: {
1245+
path: '/startup' // Your app must expose this endpoint
1246+
port: 80
1247+
scheme: 'HTTP'
1248+
}
1249+
initialDelaySeconds: 5
1250+
periodSeconds: 10
1251+
failureThreshold: 3
1252+
}
1253+
// Readiness Probe - Checks if the app is ready to receive traffic
1254+
{
1255+
type: 'Readiness'
1256+
httpGet: {
1257+
path: '/startup'
1258+
port: 80
1259+
scheme: 'HTTP'
1260+
}
1261+
initialDelaySeconds: 5
1262+
periodSeconds: 10
1263+
failureThreshold: 3
1264+
}
1265+
{
1266+
type: 'Startup'
1267+
httpGet: {
1268+
path: '/startup'
1269+
port: 80
1270+
scheme: 'HTTP'
1271+
}
1272+
initialDelaySeconds: 20 // Wait 10s before checking
1273+
periodSeconds: 5 // Check every 15s
1274+
failureThreshold: 10 // Restart if it fails 5 times
1275+
}
1276+
]
1277+
}
1278+
]
1279+
scaleSettings: {
1280+
minReplicas: container_app_deployment.container_api.minReplicas
1281+
maxReplicas: container_app_deployment.container_api.maxReplicas
1282+
rules: [
1283+
{
1284+
name: 'http-scaler'
1285+
http: {
1286+
metadata: {
1287+
concurrentRequests: '100'
1288+
}
1289+
}
1290+
}
1291+
]
1292+
}
1293+
ingressExternal: true
1294+
activeRevisionsMode: 'Single'
1295+
ingressTransport: 'auto'
1296+
ingressAllowInsecure: true
1297+
corsPolicy: {
1298+
allowedOrigins: [
1299+
'*'
1300+
]
1301+
allowedMethods: [
1302+
'GET'
1303+
'POST'
1304+
'PUT'
1305+
'DELETE'
1306+
'OPTIONS'
1307+
]
1308+
allowedHeaders: [
1309+
'Authorization'
1310+
'Content-Type'
1311+
'*'
1312+
]
1313+
}
1314+
}
1315+
dependsOn: [
1316+
avmStorageAccount_RoleAssignment_avmContainerApp_API_blob
1317+
avmStorageAccount_RoleAssignment_avmContainerApp_API_queue
1318+
avmRoleAssignment_container_app_api
1319+
]
1320+
}
1321+
11501322
output CONTAINER_WEB_APP_NAME string = avmContainerApp_Web.outputs.name
11511323
output CONTAINER_API_APP_NAME string = avmContainerApp_API.outputs.name
11521324
output CONTAINER_WEB_APP_FQDN string = avmContainerApp_Web.outputs.fqdn

0 commit comments

Comments
 (0)