-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathcontainer-app.bicep
94 lines (78 loc) · 2.37 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
// ============================================================================
// Deploy a container app with app container environment and log analytics
// ============================================================================
@description('Name of container app')
param appName string = 'vuego-demoapp'
@description('Region to deploy into')
param location string = resourceGroup().location
@description('Container image to deploy')
param image string = 'ghcr.io/benc-uk/vuego-demoapp:latest'
@description('Optional feature: OpenWeather API Key')
param weatherApiKey string = ''
@description('Optional feature: Azure AD Client ID')
param authClientId 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: 'Free'
}
}
}
resource kubeEnv 'Microsoft.Web/kubeEnvironments@2021-02-01' = {
location: location
name: environmentName
kind: 'containerenvironment'
properties: {
type: 'Managed'
appLogsConfiguration: {
destination: 'log-analytics'
logAnalyticsConfiguration: {
customerId: logWorkspace.properties.customerId
sharedKey: logWorkspace.listKeys().primarySharedKey
}
}
}
}
resource containerApp 'Microsoft.Web/containerApps@2021-03-01' = {
location: location
name: appName
properties: {
kubeEnvironmentId: kubeEnv.id
template: {
containers: [
{
image: image
name: appName
resources: {
cpu: json('0.25')
memory: '0.5Gi'
}
env: [
{
name: 'WEATHER_API_KEY'
value: weatherApiKey
}
{
name: 'AUTH_CLIENT_ID'
value: authClientId
}
]
}
]
}
configuration: {
ingress: {
external: true
targetPort: 4000
}
}
}
}
// ===== Outputs ==============================================================
output appURL string = 'https://${containerApp.properties.configuration.ingress.fqdn}'