Skip to content

Commit 2eea2fb

Browse files
feat: improve ACA store demo code and add folder structure for more demo scenarios
Signed-off-by: Kristina Devochko <[email protected]>
1 parent a70a52a commit 2eea2fb

File tree

19 files changed

+313
-48
lines changed

19 files changed

+313
-48
lines changed

aca-nginx/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# TODO

aca-nginx/parameters/dev.bicepparam

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using '../main.bicep'
2+
3+
param acaResourceGroupName = 'rg-aca-nginx-${locationPrefix}-${environment}'
4+
param environment = 'dev'
5+
param location = 'northeurope'
6+
param locationPrefix = 'neu'
7+
8+
param tags = {
9+
application: 'aca-nginx'
10+
environment: environment
11+
}
12+

aca-nginx/parameters/prod.bicepparam

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using '../main.bicep'
2+
3+
param acaResourceGroupName = 'rg-aca-nginx-${locationPrefix}-${environment}'
4+
param environment = 'prod'
5+
param location = 'northeurope'
6+
param locationPrefix = 'neu'
7+
8+
param tags = {
9+
application: 'aca-nginx'
10+
environment: environment
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# TODO
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// TODO
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// TODO
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using '../main.bicep'
2+
3+
param acaResourceGroupName = 'rg-aca-helloworld-revision-${locationPrefix}-${environment}'
4+
param environment = 'dev'
5+
param location = 'northeurope'
6+
param locationPrefix = 'neu'
7+
8+
param tags = {
9+
application: 'aca-revision-traffic-mgmt'
10+
environment: environment
11+
}
12+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using '../main.bicep'
2+
3+
param acaResourceGroupName = 'rg-aca-aci-${locationPrefix}-${environment}'
4+
param environment = 'prod'
5+
param location = 'northeurope'
6+
param locationPrefix = 'neu'
7+
8+
param tags = {
9+
application: 'aca-win-aci'
10+
environment: environment
11+
}

aca-with-windows-on-aci/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# TODO

aca-with-windows-on-aci/main.bicep

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// TODO
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// TODO
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using '../main.bicep'
2+
3+
param acaResourceGroupName = 'rg-aca-aci-${locationPrefix}-${environment}'
4+
param environment = 'dev'
5+
param location = 'northeurope'
6+
param locationPrefix = 'neu'
7+
8+
param tags = {
9+
application: 'aca-win-aci'
10+
environment: environment
11+
}
12+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using '../main.bicep'
2+
3+
param acaResourceGroupName = 'rg-aca-aci-${locationPrefix}-${environment}'
4+
param environment = 'prod'
5+
param location = 'northeurope'
6+
param locationPrefix = 'neu'
7+
8+
param tags = {
9+
application: 'aca-win-aci'
10+
environment: environment
11+
}

aks-store-on-aca/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# TODO

aks-store-on-aca/functions.bicep

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Re-used from https://github.com/Azure/bicep/issues/5703#issuecomment-2004230485
2+
@export()
3+
func replaceMultipleStrings(input string, replacements { *: string }) string => reduce(
4+
items(replacements), input, (cur, next) => replace(string(cur), next.key, next.value))

aks-store-on-aca/modules/aca-internal-apps.bicep

+7-48
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,6 @@ resource mongodb 'Microsoft.App/containerApps@2023-05-02-preview' = {
4747
cpu: json('0.5')
4848
memory: '1.0Gi'
4949
}
50-
//command: [
51-
// 'mongod'
52-
// '--dbpath'
53-
// '/data/mongoaz'
54-
// '--bind_ip_all'
55-
//]
5650
probes: [
5751
{
5852
type: 'liveness'
@@ -67,7 +61,6 @@ resource mongodb 'Microsoft.App/containerApps@2023-05-02-preview' = {
6761
]
6862
scale: {
6963
minReplicas: 1
70-
//maxReplicas: 3
7164
}
7265
}
7366
}
@@ -100,16 +93,6 @@ resource rabbitmq 'Microsoft.App/containerApps@2023-05-02-preview' = {
10093
]
10194
}
10295
secrets: [
103-
//{
104-
// name: 'queue-username'
105-
// keyVaultUrl: 'foo' // TODO
106-
// identity: managedIdentityId
107-
//}
108-
//{
109-
// name: 'queue-password'
110-
// keyVaultUrl: 'bar' // TODO
111-
// identity: managedIdentityId
112-
//}
11396
{
11497
name: 'rabbitmq-enabled-plugins'
11598
value: rabbitmqPluginsConf
@@ -129,12 +112,10 @@ resource rabbitmq 'Microsoft.App/containerApps@2023-05-02-preview' = {
129112
{
130113
name: 'RABBITMQ_DEFAULT_USER'
131114
value: queueUsername
132-
//secretRef: 'queue-username'
133115
}
134116
{
135117
name: 'RABBITMQ_DEFAULT_PASS'
136118
value: queuePass
137-
//secretRef: 'queue-password'
138119
}
139120
]
140121
volumeMounts: [
@@ -174,8 +155,7 @@ resource orderservice 'Microsoft.App/containerApps@2023-05-02-preview' = {
174155
configuration: {
175156
ingress: {
176157
external: false
177-
targetPort: 80
178-
//exposedPort: 3000
158+
targetPort: 3000
179159
transport: 'http'
180160
allowInsecure: true
181161
ipSecurityRestrictions: [
@@ -186,13 +166,6 @@ resource orderservice 'Microsoft.App/containerApps@2023-05-02-preview' = {
186166
ipAddressRange: subnetIpRange
187167
}
188168
]
189-
additionalPortMappings: [
190-
{
191-
external: false
192-
targetPort: 3000
193-
exposedPort: 3000
194-
}
195-
]
196169
}
197170
}
198171
template: {
@@ -295,7 +268,7 @@ resource makelineservice 'Microsoft.App/containerApps@2023-05-02-preview' = {
295268
configuration: {
296269
ingress: {
297270
external: false
298-
targetPort: 81
271+
targetPort: 3001
299272
transport: 'http'
300273
allowInsecure: true
301274
ipSecurityRestrictions: [
@@ -306,13 +279,6 @@ resource makelineservice 'Microsoft.App/containerApps@2023-05-02-preview' = {
306279
ipAddressRange: subnetIpRange
307280
}
308281
]
309-
additionalPortMappings: [
310-
{
311-
external: false
312-
targetPort: 3001
313-
exposedPort: 3001
314-
}
315-
]
316282
}
317283
}
318284
template: {
@@ -394,9 +360,9 @@ resource productservice 'Microsoft.App/containerApps@2023-05-02-preview' = {
394360
configuration: {
395361
ingress: {
396362
external: false
397-
targetPort: 82
363+
targetPort: 3002
398364
transport: 'http'
399-
allowInsecure: true
365+
allowInsecure: false
400366
ipSecurityRestrictions: [
401367
{
402368
name: 'AllowSnet'
@@ -405,13 +371,6 @@ resource productservice 'Microsoft.App/containerApps@2023-05-02-preview' = {
405371
ipAddressRange: subnetIpRange
406372
}
407373
]
408-
additionalPortMappings: [
409-
{
410-
external: false
411-
targetPort: 3002
412-
exposedPort: 3002
413-
}
414-
]
415374
}
416375
}
417376
template: {
@@ -530,6 +489,6 @@ resource virtualworker 'Microsoft.App/containerApps@2023-05-02-preview' = {
530489
tags: tags
531490
}
532491

533-
output makelineServiceUri string = 'http://${makelineservice.properties.configuration.ingress.fqdn}'
534-
output orderServiceUri string = 'http://${orderservice.properties.configuration.ingress.fqdn}'
535-
output productServiceUri string = 'http://${productservice.properties.configuration.ingress.fqdn}'
492+
output makelineServiceUri string = 'https://${makelineservice.properties.configuration.ingress.fqdn}'
493+
output orderServiceUri string = 'https://${orderservice.properties.configuration.ingress.fqdn}'
494+
output productServiceUri string = 'https://${productservice.properties.configuration.ingress.fqdn}'

aks-store-on-aca/modules/aca-public-apps.bicep

+83
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { replaceMultipleStrings } from '../functions.bicep'
2+
13
param environmentId string
24
param location string
35
param makelineServiceUri string
@@ -6,6 +8,20 @@ param orderServiceUri string
68
param productServiceUri string
79
param tags object
810

11+
var storeFrontNginxConfReplacements = {
12+
'{ORDER_SERVICE_URI}': orderServiceUri
13+
'{PRODUCT_SERVICE_URI}': productServiceUri
14+
}
15+
16+
var storeAdminNginxConfReplacements = {
17+
'{MAKELINE_SERVICE_URI}': makelineServiceUri
18+
'{ORDER_SERVICE_URI}': orderServiceUri
19+
'{PRODUCT_SERVICE_URI}': productServiceUri
20+
}
21+
22+
var storeFrontNginxConf = replaceMultipleStrings(loadTextContent('storeFrontNginx.conf'), storeFrontNginxConfReplacements)
23+
var storeAdminNginxConf = replaceMultipleStrings(loadTextContent('storeAdminNginx.conf'), storeAdminNginxConfReplacements)
24+
925
resource storefront 'Microsoft.App/containerApps@2023-05-02-preview' = {
1026
name: 'store-front'
1127
location: location
@@ -24,6 +40,12 @@ resource storefront 'Microsoft.App/containerApps@2023-05-02-preview' = {
2440
transport: 'http'
2541
clientCertificateMode: 'accept'
2642
}
43+
secrets: [
44+
{
45+
name: 'nginx-conf'
46+
value: storeFrontNginxConf
47+
}
48+
]
2749
}
2850
template: {
2951
containers: [
@@ -44,6 +66,17 @@ resource storefront 'Microsoft.App/containerApps@2023-05-02-preview' = {
4466
value: productServiceUri
4567
}
4668
]
69+
command: [
70+
'/bin/sh'
71+
'-c'
72+
'echo Ready to serve! && nginx -g \'daemon off;\''
73+
]
74+
volumeMounts: [
75+
{
76+
mountPath: '/etc/nginx/conf.d/'
77+
volumeName: 'nginx-conf'
78+
}
79+
]
4780
probes: [
4881
{
4982
type: 'Liveness'
@@ -81,6 +114,22 @@ resource storefront 'Microsoft.App/containerApps@2023-05-02-preview' = {
81114
scale: {
82115
minReplicas: 1
83116
}
117+
volumes: [
118+
{
119+
name: 'nginx-conf'
120+
storageType: 'Secret'
121+
secrets: [
122+
{
123+
secretRef: 'nginx-conf'
124+
path: 'default.conf'
125+
}
126+
{
127+
secretRef: 'nginx-conf'
128+
path: 'nginx.conf.template'
129+
}
130+
]
131+
}
132+
]
84133
}
85134
}
86135
}
@@ -103,16 +152,28 @@ resource storeadmin 'Microsoft.App/containerApps@2023-05-02-preview' = {
103152
transport: 'http'
104153
clientCertificateMode: 'accept'
105154
}
155+
secrets: [
156+
{
157+
name: 'nginx-conf'
158+
value: storeAdminNginxConf
159+
}
160+
]
106161
}
107162
template: {
108163
containers: [
109164
{
110165
image: 'ghcr.io/azure-samples/aks-store-demo/store-admin:latest'
166+
111167
name: 'store-admin'
112168
resources: {
113169
cpu: json('1.0')
114170
memory: '2.0Gi'
115171
}
172+
command: [
173+
'/bin/sh'
174+
'-c'
175+
'echo Ready to serve! && nginx -g \'daemon off;\''
176+
]
116177
env: [
117178
{
118179
name: 'VUE_APP_MAKELINE_SERVICE_URL'
@@ -123,6 +184,12 @@ resource storeadmin 'Microsoft.App/containerApps@2023-05-02-preview' = {
123184
value: productServiceUri
124185
}
125186
]
187+
volumeMounts: [
188+
{
189+
mountPath: '/etc/nginx/conf.d/'
190+
volumeName: 'nginx-conf'
191+
}
192+
]
126193
probes: [
127194
{
128195
type: 'Liveness'
@@ -160,6 +227,22 @@ resource storeadmin 'Microsoft.App/containerApps@2023-05-02-preview' = {
160227
scale: {
161228
minReplicas: 1
162229
}
230+
volumes: [
231+
{
232+
name: 'nginx-conf'
233+
storageType: 'Secret'
234+
secrets: [
235+
{
236+
secretRef: 'nginx-conf'
237+
path: 'default.conf'
238+
}
239+
{
240+
secretRef: 'nginx-conf'
241+
path: 'nginx.conf.template'
242+
}
243+
]
244+
}
245+
]
163246
}
164247
}
165248
tags: tags

0 commit comments

Comments
 (0)