-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy patheventgridfunction.json
196 lines (195 loc) · 8.59 KB
/
eventgridfunction.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
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"functions": [],
"variables": {
"uniqueString": "[uniqueString(subscription().subscriptionId)]",
"identityName": "[concat('id-autotagger-', variables('uniqueString'))]",
"planName": "[concat('plan-autotagger-', variables('uniqueString'))]",
"storageAccountName": "[concat('st', variables('uniqueString'))]",
"storageAccountId": "[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]",
"functionName": "[concat('func-autotagger-', variables('uniqueString'))]",
"eventGridTopic": "[concat('evt-autotagger-', variables('uniqueString'))]",
"eventGridSubscriptionName": "[concat('evs-autotagger-', variables('uniqueString'))]",
"appInsightsName": "[concat('insights-autotagger-', variables('uniqueString'))]",
"functionAppRepo": "https://github.com/acampb/AzureAutoTaggerFunction.git"
},
"resources": [
{
"name": "[variables('identityName')]",
"type": "Microsoft.ManagedIdentity/userAssignedIdentities",
"apiVersion": "2018-11-30",
"location": "[resourceGroup().location]"
},
{
"name": "[variables('planName')]",
"type": "Microsoft.Web/serverfarms",
"apiVersion": "2018-02-01",
"location": "[resourceGroup().location]",
"sku": {
"name": "Y1",
"capacity": 1
},
"properties": {
"name": "[variables('planName')]"
}
},
{
"name": "[variables('storageAccountName')]",
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2019-06-01",
"location": "[resourceGroup().location]",
"kind": "StorageV2",
"sku": {
"name": "Standard_LRS",
"tier": "Standard"
}
},
{
"name": "[variables('functionName')]",
"type": "Microsoft.Web/sites",
"apiVersion": "2020-09-01",
"location": "[resourceGroup().location]",
"kind": "functionapp",
"dependsOn": [
"[resourceId('Microsoft.Web/serverfarms', variables('planName'))]",
"[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]"
],
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', variables('identityName'))]": {}
}
},
"properties": {
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('planName'))]",
"siteConfig": {
"appSettings": [
{
"name": "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING",
"value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountid'),'2019-06-01').keys[0].value)]"
},
{
"name": "WEBSITE_CONTENTSHARE",
"value": "[toLower(variables('functionName'))]"
},
{
"name": "AzureWebJobsStorage",
"value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountid'),'2019-06-01').keys[0].value)]"
},
{
"name": "FUNCTIONS_EXTENSION_VERSION",
"value": "~3"
},
{
"name": "APPINSIGHTS_INSTRUMENTATIONKEY",
"value": "[reference(resourceId('microsoft.insights/components/', variables('appInsightsName')), '2018-05-01-preview').InstrumentationKey]"
},
{
"name": "FUNCTIONS_WORKER_RUNTIME",
"value": "powershell"
},
{
"name": "AZURE_CLIENT_ID",
"value": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', variables('identityName')), '2018-11-30', 'full').properties.clientid]"
}
]
}
},
"resources": [
{
"apiVersion": "2015-08-01",
"name": "web",
"type": "sourcecontrols",
"dependsOn": [
"[resourceId('Microsoft.Web/sites/', variables('functionName'))]"
],
"properties": {
"RepoUrl": "[variables('functionAppRepo')]",
"branch": "main",
"IsManualIntegration": true
}
}
]
},
{
"type": "Microsoft.Web/sites/config",
"apiVersion": "2018-11-01",
"name": "[concat(variables('functionName'), '/web')]",
"dependsOn": [
"[resourceId('Microsoft.Web/sites', variables('functionName'))]"
],
"properties": {
"powerShellVersion": "~7"
}
},
{
"name": "[variables('eventGridTopic')]",
"type": "Microsoft.EventGrid/systemTopics",
"apiVersion": "2020-04-01-preview",
"location": "global",
"properties": {
"source": "[subscription().id]",
"topicType": "Microsoft.Resources.Subscriptions"
}
},
{
"name": "[concat(variables('eventGridTopic'), '/', variables('eventGridSubscriptionName'))]",
"type": "Microsoft.EventGrid/systemTopics/eventSubscriptions",
"apiVersion": "2020-04-01-preview",
"dependsOn": [
"[resourceId('Microsoft.EventGrid/systemTopics', variables('eventGridTopic'))]",
"[resourceId('Microsoft.Web/sites/sourcecontrols', variables('functionName'), 'web')]"
],
"properties": {
"destination": {
"endpointType": "AzureFunction",
"properties": {
"resourceId": "[concat(resourceId('Microsoft.Web/sites', variables('functionName')), '/functions/AutoTagger')]",
"maxEventsPerBatch": 1,
"preferredBatchSizeInKilobytes": 64
}
},
"filter": {
"includedEventTypes": [
"Microsoft.Resources.ResourceWriteSuccess"
],
"advancedFilters": [
{
"key": "data.claims.appid",
"operatorType": "StringNotIn",
"values" :[
"[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', variables('identityName')), '2018-11-30', 'full').properties.clientid]"
]
}
]
}
}
},
{
"name": "[variables('appInsightsName')]",
"type": "Microsoft.Insights/components",
"apiVersion": "2018-05-01-preview",
"location": "[resourceGroup().location]",
"kind": "web",
"properties": {
"Application_Type": "web"
}
}
],
"outputs": {
"functionAppResourceId": {
"type": "string",
"value": "[resourceId('Microsoft.Web/sites', variables('functionName'))]"
},
"managedIdentityPrincipalId": {
"type": "string",
"value": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', variables('identityName')), '2018-11-30', 'full').properties.principalId]"
},
"managedIdentityClientId": {
"type": "string",
"value": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', variables('identityName')), '2018-11-30', 'full').properties.clientid]"
}
}
}