Skip to content

Commit 3e60f04

Browse files
authored
Merge pull request Azure#72 from Azure/tj/fix/bicep-ports
Parameterize ports and sendgrid integration setting
2 parents 5b6214c + a8a8e7d commit 3e60f04

File tree

7 files changed

+65
-25
lines changed

7 files changed

+65
-25
lines changed

bicep/main.bicep

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,27 +66,27 @@ param externalTasksQueueName string
6666
@description('The name of the external blob container in Azure Storage.')
6767
param externalTasksContainerBlobName string
6868

69-
@description('The name of the secret containing the External Azure Storage Access key for the Backend Background Processor Service.')
69+
@description('The name of the secret containing the External Azure Storage Access key for the backend processor service.')
7070
param externalStorageKeySecretName string
7171

72-
//Send grid
73-
@description('The name of the secret containing the SendGrid API key value for the Backend Background Processor Service.')
74-
param sendGridKeySecretName string
72+
//SendGrid
73+
@description('The name of the secret containing the SendGrid API key value for the backend processor service.')
74+
param sendGridKeySecretName string = 'sendgrid-api-key'
7575

76-
@description('The name of the Send Grid Email From.')
76+
@description('The name of the SendGrid Email From.')
7777
param sendGridEmailFrom string
7878

79-
@description('The name of the Send Grid Email From Name.')
79+
@description('The name of the SendGrid Email From Name.')
8080
param sendGridEmailFromName string
8181

82+
@secure()
83+
@description('The SendGrid API key for the backend processor service. If not provided, SendGrid integration will be disabled.')
84+
param sendGridKeySecretValue string
85+
8286
//Cron Shedule Jon
8387
@description('The cron settings for scheduled job.')
8488
param scheduledJobCron string
8589

86-
@secure()
87-
@description('The SendGrid API key for for Backend Background Processor Service.')
88-
param sendGridKeySecretValue string
89-
9090
// Dapr components
9191
@description('The name of Dapr component for the secret store building block.')
9292
// We disable lint of this line as it is not a secret but the name of the Dapr component
@@ -109,6 +109,16 @@ param backendApiServiceImage string
109109
@description('The image for the frontend web app service.')
110110
param frontendWebAppServiceImage string
111111

112+
// App Ports
113+
@description('The target and dapr port for the frontend web app service.')
114+
param frontendWebAppPortNumber int = 80
115+
116+
@description('The target and dapr port for the backend api service.')
117+
param backendApiPortNumber int = 80
118+
119+
@description('The dapr port for the backend processor service.')
120+
param backendProcessorPortNumber int = 80
121+
112122
// ------------------
113123
// RESOURCES
114124
// ------------------
@@ -217,6 +227,9 @@ module containerApps 'modules/container-apps.bicep' = {
217227
applicationInsightsName: containerAppsEnvironment.outputs.applicationInsightsName
218228
externalStorageAccountName: externalStorageAccount.outputs.storageAccountName
219229
externalStorageKeySecretName: externalStorageKeySecretName
230+
frontendWebAppPortNumber: frontendWebAppPortNumber
231+
backendApiPortNumber: backendApiPortNumber
232+
backendProcessorPortNumber: backendProcessorPortNumber
220233
}
221234
dependsOn: [
222235
daprComponents

bicep/main.parameters.json

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,8 @@
3232
"cosmosDbCollectionName": {
3333
"value": "taskscollection"
3434
},
35-
"sendGridKeySecretName": {
36-
"value": "sendgrid-api-key"
37-
},
3835
"sendGridKeySecretValue": {
39-
"value": "<SEND_GRID_API_KEY>"
36+
"value": ""
4037
},
4138
"sendGridEmailFrom": {
4239
"value": "<SEND_GRID_FROM_EMAIL>"
@@ -70,6 +67,15 @@
7067
},
7168
"frontendWebAppServiceImage": {
7269
"value": "<CONTAINER_REGISTRY_NAME>.azurecr.io/tasksmanager/tasksmanager-frontend-webapp:latest"
70+
},
71+
"frontendWebAppPortNumber": {
72+
"value": 80
73+
},
74+
"backendApiPortNumber": {
75+
"value": 80
76+
},
77+
"backendProcessorPortNumber": {
78+
"value": 80
7379
}
7480
}
7581
}

bicep/modules/container-apps-environment.bicep

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ param logAnalyticsWorkspaceName string
1818
@description(' The name of the application insights. If set, it overrides the name generated by the template.')
1919
param applicationInsightName string
2020

21-
// ------------------
22-
// VARIABLES
23-
// ------------------
24-
2521

2622
// ------------------
2723
// RESOURCES

bicep/modules/container-apps.bicep

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,21 @@ param frontendWebAppServiceImage string
7777
@description('The name of the application insights.')
7878
param applicationInsightsName string
7979

80-
var containerRegistryPullRoleGuid='7f951dda-4ed3-4680-a7ca-43fe172d538d'
80+
// App Ports
81+
@description('The target and dapr port for the frontend web app service.')
82+
param frontendWebAppPortNumber int
83+
84+
@description('The target and dapr port for the backend api service.')
85+
param backendApiPortNumber int
8186

87+
@description('The dapr port for the backend processor service.')
88+
param backendProcessorPortNumber int
89+
90+
// ------------------
91+
// VARIABLES
92+
// ------------------
93+
94+
var containerRegistryPullRoleGuid='7f951dda-4ed3-4680-a7ca-43fe172d538d'
8295

8396
// ------------------
8497
// RESOURCES
@@ -124,6 +137,7 @@ module frontendWebAppService 'container-apps/webapp-frontend-service.bicep' = {
124137
containerRegistryUserAssignedIdentityId: containerRegistryUserAssignedIdentity.id
125138
frontendWebAppServiceImage: frontendWebAppServiceImage
126139
appInsightsInstrumentationKey: applicationInsights.properties.InstrumentationKey
140+
frontendWebAppPortNumber: frontendWebAppPortNumber
127141

128142
}
129143
}
@@ -144,6 +158,7 @@ module backendApiService 'container-apps/webapi-backend-service.bicep' = {
144158
cosmosDbDatabaseName: cosmosDbDatabaseName
145159
cosmosDbCollectionName: cosmosDbCollectionName
146160
appInsightsInstrumentationKey: applicationInsights.properties.InstrumentationKey
161+
backendApiPortNumber: backendApiPortNumber
147162
}
148163
}
149164

@@ -166,6 +181,7 @@ module backendProcessorService 'container-apps/processor-backend-service.bicep'
166181
externalStorageKeySecretName:externalStorageKeySecretName
167182
backendProcessorServiceImage: backendProcessorServiceImage
168183
appInsightsInstrumentationKey: applicationInsights.properties.InstrumentationKey
184+
backendProcessorPortNumber: backendProcessorPortNumber
169185
}
170186
}
171187

bicep/modules/container-apps/processor-backend-service.bicep

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ param containerRegistryUserAssignedIdentityId string
6060
@description('The image for the backend processor service.')
6161
param backendProcessorServiceImage string
6262

63+
@description('The dapr port for the backend processor service.')
64+
param backendProcessorPortNumber int
65+
6366

6467
// ------------------
6568
// VARIABLES
@@ -111,7 +114,7 @@ resource backendProcessorService 'Microsoft.App/containerApps@2022-06-01-preview
111114
enabled: true
112115
appId: backendProcessorServiceName
113116
appProtocol: 'http'
114-
appPort: 80
117+
appPort: backendProcessorPortNumber
115118
logLevel: 'info'
116119
enableApiLogging: true
117120
}
@@ -144,7 +147,7 @@ resource backendProcessorService 'Microsoft.App/containerApps@2022-06-01-preview
144147
env: [
145148
{
146149
name: 'SendGrid__IntegrationEnabled'
147-
value: 'true'
150+
value: empty(sendGridKeySecretValue) ? 'false' : 'true'
148151
}
149152
{
150153
name: 'ApplicationInsights__InstrumentationKey'

bicep/modules/container-apps/webapi-backend-service.bicep

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ param backendApiServiceImage string
4747
@description('The Application Insights Instrumentation.')
4848
param appInsightsInstrumentationKey string
4949

50+
@description('The target and dapr port for the backend api service.')
51+
param backendApiPortNumber int
52+
5053
// ------------------
5154
// RESOURCES
5255
// ------------------
@@ -90,13 +93,13 @@ resource backendApiService 'Microsoft.App/containerApps@2022-06-01-preview' = {
9093
activeRevisionsMode: 'single'
9194
ingress: {
9295
external: false
93-
targetPort: 80
96+
targetPort: backendApiPortNumber
9497
}
9598
dapr: {
9699
enabled: true
97100
appId: backendApiServiceName
98101
appProtocol: 'http'
99-
appPort: 80
102+
appPort: backendApiPortNumber
100103
logLevel: 'info'
101104
enableApiLogging: true
102105
}

bicep/modules/container-apps/webapp-frontend-service.bicep

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ param frontendWebAppServiceImage string
3030
@description('The Application Insights Instrumentation.')
3131
param appInsightsInstrumentationKey string
3232

33+
@description('The target and dapr port for the frontend web app service.')
34+
param frontendWebAppPortNumber int
35+
3336
// ------------------
3437
// RESOURCES
3538
// ------------------
@@ -50,13 +53,13 @@ resource frontendWebAppService 'Microsoft.App/containerApps@2022-06-01-preview'
5053
activeRevisionsMode: 'single'
5154
ingress: {
5255
external: true
53-
targetPort: 80
56+
targetPort: frontendWebAppPortNumber
5457
}
5558
dapr: {
5659
enabled: true
5760
appId: frontendWebAppServiceName
5861
appProtocol: 'http'
59-
appPort: 80
62+
appPort: frontendWebAppPortNumber
6063
logLevel: 'info'
6164
enableApiLogging: true
6265
}

0 commit comments

Comments
 (0)