forked from pewill-msft/ukth-appinn-containerapps-orderapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
v1_template.bicep
253 lines (243 loc) · 6.57 KB
/
v1_template.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
param Location string
param StorageAccount_prefix string
param LogAnalytics_Workspace_Name string
param AppInsights_Name string
param ContainerApps_Environment_Name string
param ContainerApps_HttpApi_CurrentRevisionName string
param ContainerApps_HttpApi_NewRevisionName string
param Container_Registry_Name string
var StorageAccount_ApiVersion = '2018-07-01'
var StorageAccount_Queue_Name = 'demoqueue'
var Workspace_Resource_Id = LogAnalytics_Workspace_Name_resource.id
resource acr 'Microsoft.ContainerRegistry/registries@2021-12-01-preview' = {
name: Container_Registry_Name
location: Location
sku: {
name: 'Standard'
}
properties: {
adminUserEnabled: true
}
}
resource StorageAccount_Name_resource 'Microsoft.Storage/storageAccounts@2021-01-01' = {
name: '${StorageAccount_prefix}${uniqueString(resourceGroup().id)}'
location: Location
sku: {
name: 'Standard_LRS'
}
kind: 'StorageV2'
properties: {
minimumTlsVersion: 'TLS1_2'
supportsHttpsTrafficOnly: true
accessTier: 'Hot'
}
}
resource StorageAccount_Name_default_StorageAccount_Queue_Name 'Microsoft.Storage/storageAccounts/queueServices/queues@2021-01-01' = {
name: '${StorageAccount_Name_resource.name}/default/${StorageAccount_Queue_Name}'
}
resource LogAnalytics_Workspace_Name_resource 'Microsoft.OperationalInsights/workspaces@2020-08-01' = {
name: LogAnalytics_Workspace_Name
location: Location
properties: {
sku: {
name: 'PerGB2018'
}
retentionInDays: 30
features: {
searchVersion: 1
legacy: 0
enableLogAccessUsingOnlyResourcePermissions: true
}
}
}
resource AppInsights_Name_resource 'Microsoft.Insights/components@2020-02-02' = {
name: AppInsights_Name
kind: 'web'
location: Location
properties: {
Application_Type: 'web'
Flow_Type: 'Redfield'
Request_Source: 'CustomDeployment'
WorkspaceResourceId: LogAnalytics_Workspace_Name_resource.id
}
}
resource ContainerApps_Environment_Name_resource 'Microsoft.App/managedEnvironments@2022-03-01' = {
name: ContainerApps_Environment_Name
location: Location
properties: {
appLogsConfiguration: {
destination: 'log-analytics'
logAnalyticsConfiguration: {
customerId: LogAnalytics_Workspace_Name_resource.properties.customerId
sharedKey: listKeys(Workspace_Resource_Id, '2015-03-20').primarySharedKey
}
}
daprAIInstrumentationKey: AppInsights_Name_resource.properties.InstrumentationKey
daprAIConnectionString: AppInsights_Name_resource.properties.ConnectionString
}
}
resource queuereader 'Microsoft.App/containerApps@2022-03-01' = {
name: 'queuereader'
location: Location
properties: {
managedEnvironmentId: ContainerApps_Environment_Name_resource.id
configuration: {
activeRevisionsMode: 'single'
secrets: [
{
name: 'queueconnection'
value: 'DefaultEndpointsProtocol=https;AccountName=${StorageAccount_Name_resource.name};AccountKey=${listKeys(StorageAccount_Name_resource.id, StorageAccount_ApiVersion).keys[0].value};EndpointSuffix=core.windows.net'
}
]
dapr: {
enabled: true
appId: 'queuereader'
}
}
template: {
containers: [
{
image: 'krnissbrandt/aca-ws-queuereader:v1'
name: 'queuereader'
env: [
{
name: 'QueueName'
value: 'foo'
}
{
name: 'QueueConnectionString'
secretRef: 'queueconnection'
}
{
name: 'TargetApp'
value: 'storeapp'
}
{
name: 'APPLICATIONINSIGHTS_CONNECTION_STRING'
value: AppInsights_Name_resource.properties.ConnectionString
}
]
}
]
scale: {
minReplicas: 1
maxReplicas: 2
rules: [
{
name: 'myqueuerule'
azureQueue: {
queueName: 'demoqueue'
queueLength: 10
auth: [
{
secretRef: 'queueconnection'
triggerParameter: 'connection'
}
]
}
}
]
}
}
}
dependsOn: [
StorageAccount_Name_resource
]
}
resource storeapp 'Microsoft.App/containerApps@2022-03-01' = {
name: 'storeapp'
location: Location
properties: {
managedEnvironmentId: ContainerApps_Environment_Name_resource.id
configuration: {
activeRevisionsMode: 'multiple'
ingress: {
external: true
targetPort: 3000
}
dapr: {
enabled: true
appPort: 3000
}
}
template: {
containers: [
{
image: 'krnissbrandt/aca-ws-storeapp:v1'
name: 'storeapp'
env: [
{
name: 'APPLICATIONINSIGHTS_CONNECTION_STRING'
value: AppInsights_Name_resource.properties.ConnectionString
}
]
}
]
scale: {
minReplicas: 1
maxReplicas: 1
rules: []
}
}
}
}
resource httpapi 'Microsoft.App/containerApps@2022-03-01' = {
name: 'httpapi'
location: Location
properties: {
managedEnvironmentId: ContainerApps_Environment_Name_resource.id
configuration: {
activeRevisionsMode: 'multiple'
ingress: {
external: true
targetPort: 80
}
secrets: [
{
name: 'queueconnection'
value: 'DefaultEndpointsProtocol=https;AccountName=${StorageAccount_Name_resource.name};AccountKey=${listKeys(StorageAccount_Name_resource.id, StorageAccount_ApiVersion).keys[0].value};EndpointSuffix=core.windows.net'
}
]
dapr: {
enabled: false
}
}
template: {
revisionSuffix: ContainerApps_HttpApi_CurrentRevisionName
containers: [
{
image: 'krnissbrandt/aca-ws-httpapi:v1'
name: 'httpapi'
env: [
{
name: 'QueueName'
value: 'demoqueue'
}
{
name: 'QueueConnectionString'
secretRef: 'queueconnection'
}
{
name: 'APPLICATIONINSIGHTS_CONNECTION_STRING'
value: AppInsights_Name_resource.properties.ConnectionString
}
]
}
]
scale: {
minReplicas: 1
maxReplicas: 2
rules: [
{
name: 'httpscalingrule'
http: {
metadata: {
concurrentRequests: '10'
}
}
}
]
}
}
}
}