2
2
title : Resource Manager template samples for Azure Function App + Application Insights Resources
3
3
description : Sample Azure Resource Manager templates to deploy an Azure Function App with an Application Insights resource.
4
4
ms.topic : sample
5
- ms.date : 08/06/2020
5
+ ms.date : 04/27/2022
6
6
---
7
7
8
8
# Resource Manager template sample for creating Azure Function apps with Application Insights monitoring
@@ -13,113 +13,187 @@ This article includes sample [Azure Resource Manager templates](../../azure-reso
13
13
14
14
## Azure Function App
15
15
16
- The following sample creates a .NET Core 3.1 Azure Function app running on a Windows App Service plan and a [ classic Application Insights resource] ( ../app/create-new-resource.md ) with monitoring enabled.
16
+ The following sample creates a .NET Core 3.1 Azure Function app running on a Windows App Service plan and a [ classic Application Insights resource] ( ../app/create-new-resource.md ) with monitoring enabled.
17
17
18
18
### Template file
19
19
20
- ``` json
21
- {
22
- "$schema" : " http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#" ,
23
- "contentVersion" : " 1.0.0.0" ,
24
- "parameters" : {
25
- "subscriptionId" : {
26
- "type" : " string"
27
- },
28
- "name" : {
29
- "type" : " string"
30
- },
31
- "location" : {
32
- "type" : " string"
33
- },
34
- "hostingPlanName" : {
35
- "type" : " string"
36
- },
37
- "serverFarmResourceGroup" : {
38
- "type" : " string"
39
- },
40
- "alwaysOn" : {
41
- "type" : " bool"
42
- },
43
- "storageAccountName" : {
44
- "type" : " string"
20
+ # [ Bicep] ( #tab/bicep )
21
+
22
+ ``` bicep
23
+ param subscriptionId string
24
+ param name string
25
+ param location string
26
+ param hostingPlanName string
27
+ param serverFarmResourceGroup string
28
+ param alwaysOn bool
29
+ param storageAccountName string
30
+
31
+ resource site 'Microsoft.Web/sites@2021-03-01' = {
32
+ name: name
33
+ kind: 'functionapp'
34
+ location: location
35
+ properties: {
36
+ siteConfig: {
37
+ appSettings: [
38
+ {
39
+ name: 'FUNCTIONS_EXTENSION_VERSION'
40
+ value: '~3'
45
41
}
46
- },
47
- "resources" : [
48
42
{
49
- "apiVersion" : " 2018-11-01" ,
50
- "name" : " [parameters('name')]" ,
51
- "type" : " Microsoft.Web/sites" ,
52
- "kind" : " functionapp" ,
53
- "location" : " [parameters('location')]" ,
54
- "tags" : {},
55
- "dependsOn" : [
56
- " microsoft.insights/components/function-app-01" ,
57
- " [concat('Microsoft.Storage/storageAccounts/', parameters('storageAccountName'))]"
58
- ],
59
- "properties" : {
60
- "name" : " [parameters('name')]" ,
61
- "siteConfig" : {
62
- "appSettings" : [
63
- {
64
- "name" : " FUNCTIONS_EXTENSION_VERSION" ,
65
- "value" : " ~3"
66
- },
67
- {
68
- "name" : " FUNCTIONS_WORKER_RUNTIME" ,
69
- "value" : " dotnet"
70
- },
71
- {
72
- "name" : " APPINSIGHTS_INSTRUMENTATIONKEY" ,
73
- "value" : " [reference('microsoft.insights/components/function-app-01', '2015-05-01').InstrumentationKey]"
74
- },
75
- {
76
- "name" : " APPLICATIONINSIGHTS_CONNECTION_STRING" ,
77
- "value" : " [reference('microsoft.insights/components/function-app-01', '2015-05-01').ConnectionString]"
78
- },
79
- {
80
- "name" : " AzureWebJobsStorage" ,
81
- "value" : " [concat('DefaultEndpointsProtocol=https;AccountName=',parameters('storageAccountName'),';AccountKey=',listKeys(resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName')), '2019-06-01').keys[0].value,';EndpointSuffix=','core.windows.net')]"
82
- }
83
- ],
84
- "alwaysOn" : " [parameters('alwaysOn')]"
85
- },
86
- "serverFarmId" : " [concat('/subscriptions/', parameters('subscriptionId'),'/resourcegroups/', parameters('serverFarmResourceGroup'), '/providers/Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]" ,
87
- "clientAffinityEnabled" : true
88
- }
89
- },
43
+ name: 'FUNCTIONS_WORKER_RUNTIME'
44
+ value: 'dotnet'
45
+ }
90
46
{
91
- "apiVersion" : " 2015-05-01" ,
92
- "name" : " function-app-01" ,
93
- "type" : " microsoft.insights/components" ,
94
- "location" : " centralus" ,
95
- "tags" : {},
96
- "properties" : {
97
- "ApplicationId" : " [parameters('name')]" ,
98
- "Request_Source" : " IbizaWebAppExtensionCreate"
99
- }
100
- },
47
+ name: 'APPINSIGHTS_INSTRUMENTATIONKEY'
48
+ value: reference('microsoft.insights/components/function-app-01', '2015-05-01').InstrumentationKey
49
+ }
50
+ {
51
+ name: 'APPLICATIONINSIGHTS_CONNECTION_STRING'
52
+ value: reference('microsoft.insights/components/function-app-01', '2015-05-01').ConnectionString
53
+ }
101
54
{
102
- "apiVersion" : " 2019-06-01" ,
103
- "type" : " Microsoft.Storage/storageAccounts" ,
104
- "name" : " [parameters('storageAccountName')]" ,
105
- "location" : " [parameters('location')]" ,
106
- "tags" : {},
107
- "sku" : {
108
- "name" : " Standard_LRS"
55
+ name: 'AzureWebJobsStorage'
56
+ value: 'DefaultEndpointsProtocol=https;AccountName=${storageAccountName};AccountKey=${storageAccount.listKeys().keys[0]};EndpointSuffix=core.windows.net'
57
+ }
58
+ ]
59
+ alwaysOn: alwaysOn
60
+ }
61
+ serverFarmId: '/subscriptions/${subscriptionId}/resourcegroups/${serverFarmResourceGroup}/providers/Microsoft.Web/serverfarms/${hostingPlanName}'
62
+ clientAffinityEnabled: true
63
+ }
64
+ dependsOn: [
65
+ functionApp
66
+ ]
67
+ }
68
+
69
+ resource functionApp 'microsoft.insights/components@2015-05-01' = {
70
+ name: 'function-app-01'
71
+ location: location
72
+ kind: 'web'
73
+ properties: {
74
+ Application_Type: 'web'
75
+ Request_Source: 'rest'
76
+ }
77
+ }
78
+
79
+ resource storageAccount 'Microsoft.Storage/storageAccounts@2021-08-01' = {
80
+ name: storageAccountName
81
+ location: location
82
+ sku: {
83
+ name: 'Standard_LRS'
84
+ }
85
+ kind: 'Storage'
86
+ properties: {
87
+ supportsHttpsTrafficOnly: true
88
+ }
89
+ }
90
+ ```
91
+
92
+ # [ JSON] ( #tab/json )
93
+
94
+ ``` json
95
+ {
96
+ "$schema" : " https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#" ,
97
+ "contentVersion" : " 1.0.0.0" ,
98
+ "parameters" : {
99
+ "subscriptionId" : {
100
+ "type" : " string"
101
+ },
102
+ "name" : {
103
+ "type" : " string"
104
+ },
105
+ "location" : {
106
+ "type" : " string"
107
+ },
108
+ "hostingPlanName" : {
109
+ "type" : " string"
110
+ },
111
+ "serverFarmResourceGroup" : {
112
+ "type" : " string"
113
+ },
114
+ "alwaysOn" : {
115
+ "type" : " bool"
116
+ },
117
+ "storageAccountName" : {
118
+ "type" : " string"
119
+ }
120
+ },
121
+ "resources" : [
122
+ {
123
+ "type" : " Microsoft.Web/sites" ,
124
+ "apiVersion" : " 2021-03-01" ,
125
+ "name" : " [parameters('name')]" ,
126
+ "kind" : " functionapp" ,
127
+ "location" : " [parameters('location')]" ,
128
+ "properties" : {
129
+ "siteConfig" : {
130
+ "appSettings" : [
131
+ {
132
+ "name" : " FUNCTIONS_EXTENSION_VERSION" ,
133
+ "value" : " ~3"
134
+ },
135
+ {
136
+ "name" : " FUNCTIONS_WORKER_RUNTIME" ,
137
+ "value" : " dotnet"
138
+ },
139
+ {
140
+ "name" : " APPINSIGHTS_INSTRUMENTATIONKEY" ,
141
+ "value" : " [reference('microsoft.insights/components/function-app-01', '2015-05-01').InstrumentationKey]"
142
+ },
143
+ {
144
+ "name" : " APPLICATIONINSIGHTS_CONNECTION_STRING" ,
145
+ "value" : " [reference('microsoft.insights/components/function-app-01', '2015-05-01').ConnectionString]"
109
146
},
110
- "properties" : {
111
- "supportsHttpsTrafficOnly" : true
147
+ {
148
+ "name" : " AzureWebJobsStorage" ,
149
+ "value" : " [format('DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1};EndpointSuffix=core.windows.net', parameters('storageAccountName'), listKeys(resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName')), '2021-08-01').keys[0])]"
112
150
}
113
- }
114
- ]
151
+ ],
152
+ "alwaysOn" : " [parameters('alwaysOn')]"
153
+ },
154
+ "serverFarmId" : " [format('/subscriptions/{0}/resourcegroups/{1}/providers/Microsoft.Web/serverfarms/{2}', parameters('subscriptionId'), parameters('serverFarmResourceGroup'), parameters('hostingPlanName'))]" ,
155
+ "clientAffinityEnabled" : true
156
+ },
157
+ "dependsOn" : [
158
+ " [resourceId('Microsoft.Insights/components', 'function-app-01')]" ,
159
+ " [resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName'))]"
160
+ ]
161
+ },
162
+ {
163
+ "type" : " Microsoft.Insights/components" ,
164
+ "apiVersion" : " 2015-05-01" ,
165
+ "name" : " function-app-01" ,
166
+ "location" : " [parameters('location')]" ,
167
+ "kind" : " web" ,
168
+ "properties" : {
169
+ "Application_Type" : " web" ,
170
+ "Request_Source" : " rest"
171
+ }
172
+ },
173
+ {
174
+ "type" : " Microsoft.Storage/storageAccounts" ,
175
+ "apiVersion" : " 2021-08-01" ,
176
+ "name" : " [parameters('storageAccountName')]" ,
177
+ "location" : " [parameters('location')]" ,
178
+ "sku" : {
179
+ "name" : " Standard_LRS"
180
+ },
181
+ "kind" : " Storage" ,
182
+ "properties" : {
183
+ "supportsHttpsTrafficOnly" : true
184
+ }
185
+ }
186
+ ]
115
187
}
116
188
```
117
189
190
+ ---
191
+
118
192
### Parameters file
119
193
120
194
``` json
121
195
{
122
- "$schema" : " https://schema.management.azure.com/schemas/2015-01 -01/deploymentParameters.json#" ,
196
+ "$schema" : " https://schema.management.azure.com/schemas/2019-04 -01/deploymentParameters.json#" ,
123
197
"contentVersion" : " 1.0.0.0" ,
124
198
"parameters" : {
125
199
"subscriptionId" : {
0 commit comments