Skip to content

Commit 457d100

Browse files
Add demo containerapp
1 parent eab498d commit 457d100

File tree

2 files changed

+161
-0
lines changed

2 files changed

+161
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: ContainerApp
2+
summary: This is a deployment of a Azure Container App using Bicep.
3+
description: Deploys a Container App within a Container App Environment, along with a Log Analytics Workspace
4+
templatePath: main.bicep
5+
parameters:
6+
- id: "cpuCore"
7+
name: "Number of CPU Cores"
8+
description: "Number of CPU Cores available to the Container App"
9+
type: "string"
10+
default: ".5"
11+
allowed:
12+
- "0.25"
13+
- "0.5"
14+
- "0.75"
15+
- "1"
16+
- "1.25"
17+
- "1.5"
18+
- "1.75"
19+
- "2"
20+
- id: "memorySize"
21+
name: "Amount of Memory (GB)"
22+
description: "Amount of memory available to the Container App"
23+
type: "string"
24+
default: "1"
25+
allowed:
26+
- "0.5"
27+
- "1"
28+
- "1.5"
29+
- "2"
30+
- "3"
31+
- "3.5"
32+
- "4"
33+
- id: "containerImage"
34+
name: "Container Image"
35+
description: "The container image to deploy"
36+
type: "string"
37+
default: "mcr.microsoft.com/azuredocs/containerapps-helloworld:latest"
38+
- id: "location"
39+
name: "location"
40+
description: "Location to deploy the environment resources. If not specified, will deploy to the region of the project"
41+
type: "string"
42+
runner: Bicep
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
@description('Specifies the name of the container app.')
2+
param containerAppName string = 'app-${uniqueString(resourceGroup().id)}'
3+
4+
@description('Specifies the name of the container app environment.')
5+
param containerAppEnvName string = 'env-${uniqueString(resourceGroup().id)}'
6+
7+
@description('Specifies the name of the log analytics workspace.')
8+
param containerAppLogAnalyticsName string = 'log-${uniqueString(resourceGroup().id)}'
9+
10+
@description('Specifies the location for all resources.')
11+
param location string = resourceGroup().location
12+
13+
@description('Specifies the docker container image to deploy.')
14+
param containerImage string = 'mcr.microsoft.com/azuredocs/containerapps-helloworld:latest'
15+
16+
@description('Specifies the container port.')
17+
param targetPort int = 80
18+
19+
@description('Number of CPU cores the container can use. Can be with a maximum of two decimals.')
20+
@allowed([
21+
'0.25'
22+
'0.5'
23+
'0.75'
24+
'1'
25+
'1.25'
26+
'1.5'
27+
'1.75'
28+
'2'
29+
])
30+
param cpuCore string = '0.5'
31+
32+
@description('Amount of memory (in gibibytes, GiB) allocated to the container up to 4GiB. Can be with a maximum of two decimals. Ratio with CPU cores must be equal to 2.')
33+
@allowed([
34+
'0.5'
35+
'1'
36+
'1.5'
37+
'2'
38+
'3'
39+
'3.5'
40+
'4'
41+
])
42+
param memorySize string = '1'
43+
44+
@description('Minimum number of replicas that will be deployed')
45+
@minValue(0)
46+
@maxValue(25)
47+
param minReplicas int = 1
48+
49+
@description('Maximum number of replicas that will be deployed')
50+
@minValue(0)
51+
@maxValue(25)
52+
param maxReplicas int = 3
53+
54+
resource logAnalytics 'Microsoft.OperationalInsights/workspaces@2022-10-01' = {
55+
name: containerAppLogAnalyticsName
56+
location: location
57+
properties: {
58+
sku: {
59+
name: 'PerGB2018'
60+
}
61+
}
62+
}
63+
64+
resource containerAppEnv 'Microsoft.App/managedEnvironments@2022-06-01-preview' = {
65+
name: containerAppEnvName
66+
location: location
67+
sku: {
68+
name: 'Consumption'
69+
}
70+
properties: {
71+
appLogsConfiguration: {
72+
destination: 'log-analytics'
73+
logAnalyticsConfiguration: {
74+
customerId: logAnalytics.properties.customerId
75+
sharedKey: logAnalytics.listKeys().primarySharedKey
76+
}
77+
}
78+
}
79+
}
80+
81+
resource containerApp 'Microsoft.App/containerApps@2022-06-01-preview' = {
82+
name: containerAppName
83+
location: location
84+
properties: {
85+
managedEnvironmentId: containerAppEnv.id
86+
configuration: {
87+
ingress: {
88+
external: true
89+
targetPort: targetPort
90+
allowInsecure: false
91+
traffic: [
92+
{
93+
latestRevision: true
94+
weight: 100
95+
}
96+
]
97+
}
98+
}
99+
template: {
100+
revisionSuffix: 'firstrevision'
101+
containers: [
102+
{
103+
name: containerAppName
104+
image: containerImage
105+
resources: {
106+
cpu: json(cpuCore)
107+
memory: '${memorySize}Gi'
108+
}
109+
}
110+
]
111+
scale: {
112+
minReplicas: minReplicas
113+
maxReplicas: maxReplicas
114+
}
115+
}
116+
}
117+
}
118+
119+
output containerAppFQDN string = containerApp.properties.configuration.ingress.fqdn

0 commit comments

Comments
 (0)