-
Notifications
You must be signed in to change notification settings - Fork 113
/
Copy pathcontainer-app.bicep
107 lines (88 loc) · 2.76 KB
/
container-app.bicep
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
// ============================================================================
// Deploy a container app with app container environment and log analytics
// ============================================================================
@description('Name of container app')
param appName string = 'nodejs-demoapp'
@description('Region to deploy into')
param location string = resourceGroup().location
@description('Container image to deploy')
param image string = 'ghcr.io/benc-uk/nodejs-demoapp:latest'
@description('Optional feature: OpenWeather API Key')
param weatherApiKey string = ''
@description('Optional feature: Enable Azure App Insights')
param appInsightsConnString string = ''
@description('Optional feature: Enable todo app with MongoDB')
param todoMongoConnstr string = ''
@description('Optional feature: Enable auth with EntraID, and a client id')
param entraAppId string = ''
// ===== Variables ============================================================
var logWorkspaceName = '${resourceGroup().name}-logs'
var environmentName = '${resourceGroup().name}-environment'
// ===== Modules & Resources ==================================================
resource logWorkspace 'Microsoft.OperationalInsights/workspaces@2020-08-01' = {
location: location
name: logWorkspaceName
properties: {
sku: {
name: 'PerGB2018'
}
}
}
resource appEnv 'Microsoft.App/managedEnvironments@2024-03-01' = {
location: location
name: environmentName
properties: {
appLogsConfiguration: {
destination: 'log-analytics'
logAnalyticsConfiguration: {
customerId: logWorkspace.properties.customerId
sharedKey: logWorkspace.listKeys().primarySharedKey
}
}
}
}
resource containerApp 'Microsoft.App/containerApps@2024-03-01' = {
location: location
name: appName
properties: {
environmentId: appEnv.id
template: {
containers: [
{
image: image
name: appName
resources: {
cpu: json('0.25')
memory: '0.5Gi'
}
env: [
{
name: 'WEATHER_API_KEY'
value: weatherApiKey
}
{
name: 'APPINSIGHTS_CONNECTION_STRING'
value: appInsightsConnString
}
{
name: 'TODO_MONGO_CONNSTR'
value: todoMongoConnstr
}
{
name: 'ENTRA_APP_ID'
value: entraAppId
}
]
}
]
}
configuration: {
ingress: {
external: true
targetPort: 3000
}
}
}
}
// ===== Outputs ==============================================================
output appURL string = 'https://${containerApp.properties.configuration.ingress.fqdn}'