-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathmain.bicep
155 lines (147 loc) · 3.35 KB
/
main.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
@minLength(3)
@maxLength(11)
param namePrefix string
param location string = resourceGroup().location
resource cosmos 'Microsoft.DocumentDB/databaseAccounts@2021-04-15' = {
name: '${namePrefix}cosmos'
kind: 'MongoDB'
location: location
properties: {
consistencyPolicy: {
defaultConsistencyLevel: 'Session'
}
locations: [
{
locationName: location
failoverPriority: 0
isZoneRedundant: false
}
]
databaseAccountOfferType: 'Standard'
enableAutomaticFailover: false
enableMultipleWriteLocations: false
apiProperties: {
serverVersion: '4.0'
}
capabilities: [
{
name: 'EnableServerless'
}
]
}
resource database 'mongodbDatabases' = {
name: 'Pets'
properties: {
resource: {
id: 'Pets'
}
}
resource list 'collections' = {
name: 'PetList'
properties: {
resource: {
id: 'PetList'
shardKey: {
_id: 'Hash'
}
indexes: [
{
key: {
keys: [
'_id'
]
}
}
]
}
}
}
}
}
resource logAnalytics 'Microsoft.OperationalInsights/workspaces@2021-12-01-preview' = {
name: '${namePrefix}loganalytics'
location: location
properties: {
sku: {
name: 'PerGB2018'
}
}
}
resource containerRegistry 'microsoft.containerregistry/registries@2021-12-01-preview' = {
name: '${namePrefix}acr'
location: location
properties: {
adminUserEnabled: true
}
sku: {
name: 'Basic'
}
}
resource conatinerAppEnvironment 'Microsoft.App/managedEnvironments@2022-03-01' = {
name: '${namePrefix}containerappenvironment'
location: location
properties: {
appLogsConfiguration: {
destination: 'log-analytics'
logAnalyticsConfiguration: {
customerId: logAnalytics.properties.customerId
sharedKey: logAnalytics.listKeys().primarySharedKey
}
}
}
}
resource containerApp 'Microsoft.App/containerApps@2022-03-01' = {
name: '${namePrefix}containerapp'
location: location
properties: {
managedEnvironmentId: conatinerAppEnvironment.id
configuration: {
ingress: {
external: true
targetPort: 80
allowInsecure: false
traffic: [
{
latestRevision: true
weight: 100
}
]
}
registries: [
{
server: containerRegistry.name
username: containerRegistry.properties.loginServer
passwordSecretRef: 'container-registry-password'
}
]
secrets: [
{
name: 'container-registry-password'
value: containerRegistry.listCredentials().passwords[0].value
}
{
name: 'cosmosdb-connection-string'
value: cosmos.listConnectionStrings().connectionStrings[0].connectionString
}
]
}
template: {
containers: [
{
name: '${namePrefix}containerapp'
image: 'mcr.microsoft.com/azuredocs/containerapps-helloworld:latest'
env: [
{
name: 'MONGODB_URI'
secretRef: 'cosmosdb-connection-string'
}
]
resources: {
cpu: '0.5'
memory: '1.0Gi'
}
}
]
}
}
}