This repository has been archived by the owner on Apr 26, 2023. It is now read-only.
forked from benc-uk/dotnet-demoapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontainer-app.bicep
127 lines (110 loc) · 3.47 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// ============================================================================
// Deploy a container app with app container environment and log analytics
// ============================================================================
@description('Name of container app')
param appName string = 'dotnet-demoapp'
@description('Region to deploy into')
param location string = resourceGroup().location
@description('Container image to deploy')
param image string = 'ghcr.io/benc-uk/dotnet-demoapp:latest'
@description('Optional feature: OpenWeather API Key')
param weatherApiKey string = ''
@description('Optional feature: Enable Azure App Insights')
param appInsightsInstrumentationKey string = ''
@description('Optional feature: Enable auth with Azure AD, client id')
param azureAdClientId string = ''
@description('Optional feature: Enable auth with Azure AD, client secret')
@secure()
param azureAdClientSecret string = ''
@description('Optional feature: Enable auth with Azure AD, tenant id')
param azureAdTenantId string = 'common'
@description('Optional feature: Enable auth with Azure AD, instance')
param azureAdInstance string = 'https://login.microsoftonline.com/'
// ===== 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__ApiKey'
value: weatherApiKey
}
{
name: 'ApplicationInsights__InstrumentationKey'
value: appInsightsInstrumentationKey
}
{
name: 'AzureAd__ClientId'
value: azureAdClientId
}
{
name: 'AzureAd__ClientSecret'
secretRef: 'azure-ad-client-secret'
}
{
name: 'AzureAd__Instance'
value: azureAdInstance
}
{
name: 'AzureAd__TenantId'
value: azureAdTenantId
}
]
}
]
}
configuration: {
secrets: [
{
name: 'azure-ad-client-secret'
value: azureAdClientSecret
}
]
ingress: {
allowInsecure: true
external: true
targetPort: 5000
}
}
}
}
// ===== Outputs ==============================================================
output appURL string = 'https://${containerApp.properties.configuration.ingress.fqdn}'