-
Notifications
You must be signed in to change notification settings - Fork 0
/
azuredeploy.json
260 lines (260 loc) · 8.96 KB
/
azuredeploy.json
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
254
255
256
257
258
259
260
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"uniqueSeed": {
"type": "string",
"defaultValue": "[concat(subscription().subscriptionId, resourceGroup().name)]"
},
"uniqueSuffix": {
"type": "string",
"defaultValue": "[uniqueString(parameters('uniqueSeed'))]"
},
"environment_name": {
"type": "string",
"defaultValue": "[concat('env-', parameters('uniqueSuffix'))]"
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]"
},
"storage_account_name": {
"type": "string",
"defaultValue": "[concat('storage', parameters(replace('uniqueSuffix', '-', '')))]"
},
"blobContainerName": {
"type": "string",
"defaultValue": "orders"
},
"managedIdentityName": {
"type": "string",
"defaultValue": "nodeapp-identity"
}
},
"variables": {
"logAnalyticsWorkspaceName": "[concat('logs-', parameters('environment_name'))]",
"appInsightsName": "[concat('appins-', parameters('environment_name'))]",
"dataContributorRoleDefinitionId": "ba92f5b4-2d11-453d-a403-e96b0029c9fe"
},
"resources": [
{
"type": "Microsoft.OperationalInsights/workspaces",
"apiVersion": "2021-06-01",
"name": "[variables('logAnalyticsWorkspaceName')]",
"location": "[parameters('location')]",
"properties": {
"retentionInDays": 30,
"features": {
"searchVersion": 1
},
"sku": {
"name": "PerGB2018"
}
}
},
{
"type": "Microsoft.Insights/components",
"apiVersion": "2020-02-02",
"name": "[variables('appInsightsName')]",
"location": "[parameters('location')]",
"kind": "web",
"dependsOn": [
"[resourceId('Microsoft.OperationalInsights/workspaces/', variables('logAnalyticsWorkspaceName'))]"
],
"properties": {
"Application_Type": "web",
"WorkspaceResourceId": "[resourceId('Microsoft.OperationalInsights/workspaces/', variables('logAnalyticsWorkspaceName'))]"
}
},
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2021-09-01",
"name": "[parameters('storage_account_name')]",
"location": "[parameters('location')]",
"sku": {
"name": "Standard_LRS"
},
"kind": "StorageV2",
"properties": {},
"resources": [
{
"type": "blobServices",
"apiVersion": "2021-09-01",
"name": "default",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', parameters('storage_account_name'))]"
],
"resources": [
{
"type": "containers",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts/blobServices', parameters('storage_account_name'), 'default')]"
],
"apiVersion": "2021-09-01",
"name": "[parameters('blobContainerName')]"
}
]
}
]
},
{
"type": "Microsoft.ManagedIdentity/userAssignedIdentities",
"apiVersion": "2022-01-31-preview",
"name": "[parameters('managedIdentityName')]",
"location": "[parameters('location')]"
},
{
"type": "Microsoft.Authorization/roleAssignments",
"apiVersion": "2020-04-01-preview",
"name": "[guid(resourceGroup().id, extensionResourceId(resourceId('Microsoft.Storage/storageAccounts', parameters('storage_account_name')), 'Microsoft.Authorization/roleDefinitions', variables('dataContributorRoleDefinitionId')))]",
"dependsOn": [
"[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('managedIdentityName'))]",
"[resourceId('Microsoft.Storage/storageAccounts', parameters('storage_account_name'))]"
],
"properties": {
"roleDefinitionId": "[extensionResourceId(resourceId('Microsoft.Storage/storageAccounts', parameters('storage_account_name')), 'Microsoft.Authorization/roleDefinitions', variables('dataContributorRoleDefinitionId'))]",
"principalId": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('managedIdentityName'))).principalId]",
"principalType": "ServicePrincipal"
}
},
{
"type": "Microsoft.App/managedEnvironments",
"apiVersion": "2022-03-01",
"name": "[parameters('environment_name')]",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.Insights/components/', variables('appInsightsName'))]"
],
"properties": {
"daprAIInstrumentationKey": "[reference(resourceId('Microsoft.Insights/components/', variables('appInsightsName')), '2020-02-02').InstrumentationKey]",
"appLogsConfiguration": {
"destination": "log-analytics",
"logAnalyticsConfiguration": {
"customerId": "[reference(resourceId('Microsoft.OperationalInsights/workspaces/', variables('logAnalyticsWorkspaceName')), '2021-06-01').customerId]",
"sharedKey": "[listKeys(resourceId('Microsoft.OperationalInsights/workspaces/', variables('logAnalyticsWorkspaceName')), '2021-06-01').primarySharedKey]"
}
}
},
"resources": [
{
"type": "daprComponents",
"name": "statestore",
"apiVersion": "2022-03-01",
"dependsOn": [
"[resourceId('Microsoft.App/managedEnvironments/', parameters('environment_name'))]"
],
"properties": {
"componentType": "state.azure.blobstorage",
"version": "v1",
"ignoreErrors": false,
"initTimeout": "5s",
"metadata": [
{
"name": "accountName",
"value": "[parameters('storage_account_name')]"
},
{
"name": "containerName",
"value": "[parameters('blobContainerName')]"
},
{
"name": "azureClientId",
"value": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('managedIdentityName'))).clientId]"
}
],
"scopes": ["nodeapp"]
}
}
]
},
{
"type": "Microsoft.App/containerApps",
"apiVersion": "2022-03-01",
"name": "pythonapp",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.App/managedEnvironments/', parameters('environment_name'))]",
"[resourceId('Microsoft.App/containerApps/', 'nodeapp')]"
],
"properties": {
"managedEnvironmentId": "[resourceId('Microsoft.App/managedEnvironments/', parameters('environment_name'))]",
"configuration": {
"dapr": {
"enabled": true,
"appId": "pythonapp"
}
},
"template": {
"containers": [
{
"image": "dapriosamples/hello-k8s-python:latest",
"name": "hello-k8s-python",
"resources": {
"cpu": 0.5,
"memory": "1.0Gi"
}
}
],
"scale": {
"minReplicas": 1,
"maxReplicas": 1
}
}
}
},
{
"type": "Microsoft.App/containerApps",
"apiVersion": "2022-03-01",
"name": "nodeapp",
"dependsOn": [
"[resourceId('Microsoft.App/managedEnvironments/', parameters('environment_name'))]",
"[resourceId('Microsoft.Storage/storageAccounts', parameters('storage_account_name'))]",
"[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('managedIdentityName'))]"
],
"location": "[parameters('location')]",
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('managedIdentityName'))]": {}
}
},
"properties": {
"managedEnvironmentId": "[resourceId('Microsoft.App/managedEnvironments/', parameters('environment_name'))]",
"configuration": {
"ingress": {
"external": false,
"targetPort": 3000
},
"dapr": {
"enabled": true,
"appId": "nodeapp",
"appProcotol": "http",
"appPort": 3000
}
},
"template": {
"containers": [
{
"image": "dapriosamples/hello-k8s-node:latest",
"name": "hello-k8s-node",
"env": [
{
"name": "APP_PORT",
"value": "3000"
}
],
"resources": {
"cpu": 0.5,
"memory": "1.0Gi"
}
}
],
"scale": {
"minReplicas": 1,
"maxReplicas": 1
}
}
}
}
]
}