-
Notifications
You must be signed in to change notification settings - Fork 1
/
azuredeploy.json
202 lines (202 loc) · 9.3 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
{
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "The location of the resources (Azure region)"
}
},
"functionAppName": {
"type": "string",
"defaultValue": "[concat('func',uniqueString(resourceGroup().id, deployment().name))]",
"metadata": {
"description": "The name to be given to the Azure Function App where the GetToken function will reside."
}
},
"roleName": {
"type": "object",
"defaultValue": {
"name": "Owner",
"id": "8e3af657-a8ff-443c-a75c-2fe8c4bcb635"
},
"allowedValues": [
{
"name": "Owner",
"id": "8e3af657-a8ff-443c-a75c-2fe8c4bcb635"
},
{
"name": "Contributor",
"id": "b24988ac-6180-42a0-ab88-20f7382dd24c"
},
{
"name": "Reader",
"id": "acdd72a7-3385-48ef-bd42-f606fba81ae7"
}
],
"metadata": {
"description": "One of the 3 most common built-in roles (Owner, Contributor, Reader) to be assigned to the principal id of the function app over the scope of the current resource group. Other built-in roles or a custom role can be added to the allowedValues list by editing the template. Use https://docs.microsoft.com/en-us/azure/role-based-access-control/built-in-roles as a reference for figuring out the ids for built-in roles."
}
},
"artifactsBaseUrl": {
"type": "string",
"metadata": {
"artifactsBaseUrl": "The base URL of the ARM Template's resources (child templates and supporting VM extension scripts). For Azure Marketplace gallery packages, this value is passed by the Azure portal."
},
"defaultValue": "https://raw.githubusercontent.com/StratusOn/MSI-GetToken-FunctionApp/master"
},
"artifactsBaseUrlSasToken": {
"type": "securestring",
"metadata": {
"description": "The SAS token (including the leading '?') if artifactsBaseUrl represents an Azure Storage account. The SAS token should be setup to have at least read on the blob or read+list on the container."
},
"defaultValue": ""
}
},
"variables": {
"functionName": "GetToken",
"createFunctionAppUrl": "[concat(parameters('artifactsBaseUrl'), '/createFunctionApp.json', parameters('artifactsBaseUrlSasToken'))]",
"applyRbacUrl": "[concat(parameters('artifactsBaseUrl'), '/applyRBAC.json', parameters('artifactsBaseUrlSasToken'))]",
"uniqueSuffix": "[uniqueString(resourceGroup().id, deployment().name)]",
"storageAccountName": "[concat('stor', variables('uniqueSuffix'))]",
"hostingPlanName": "[concat('plan', variables('uniqueSuffix'))]",
"roleAssignmentId": "[guid(resourceGroup().id, deployment().name)]",
"functionAppIdentityResourceId": "[concat(resourceId('Microsoft.Web/sites', parameters('functionAppName')),'/providers/Microsoft.ManagedIdentity/Identities/default')]",
"roleDefinitionId": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Authorization/roleDefinitions/', parameters('roleName').id)]",
"storageApiVersion": "2016-12-01",
"appServiceApiVersion": "2016-08-01",
"hostingPlanApiVersion": "2016-09-01",
"roleAssignmentsApiVersion": "2016-07-01",
"msiApiVersion": "2015-08-31-PREVIEW",
"deploymentsApiVersion": "2016-09-01"
},
"resources": [
{
"apiVersion": "[variables('storageApiVersion')]",
"type": "Microsoft.Storage/storageAccounts",
"name": "[variables('storageAccountName')]",
"location": "[parameters('location')]",
"kind": "Storage",
"sku": {
"name": "Standard_LRS"
},
"tags": {
"displayName": "FunctionsStorageAccount",
"applicationName": "MSITokenFunctionApp"
}
},
{
"name": "createFunctionApp",
"type": "Microsoft.Resources/deployments",
"apiVersion": "[variables('deploymentsApiVersion')]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]"
],
"properties": {
"mode": "Incremental",
"templateLink": {
"uri": "[variables('createFunctionAppUrl')]",
"contentVersion": "1.0.0.0"
},
"parameters": {
"location": {
"value": "[parameters('location')]"
},
"storageAccountName": {
"value": "[variables('storageAccountName')]"
},
"hostingPlanName": {
"value": "[variables('hostingPlanName')]"
},
"functionAppName": {
"value": "[parameters('functionAppName')]"
},
"functionName": {
"value": "[variables('functionName')]"
},
"storageApiVersion": {
"value": "[variables('storageApiVersion')]"
},
"appServiceApiVersion": {
"value": "[variables('appServiceApiVersion')]"
},
"hostingPlanApiVersion": {
"value": "[variables('hostingPlanApiVersion')]"
}
}
}
},
{
"name": "applyRbac",
"type": "Microsoft.Resources/deployments",
"apiVersion": "[variables('deploymentsApiVersion')]",
"dependsOn": [
"Microsoft.Resources/deployments/createFunctionApp"
],
"properties": {
"mode": "Incremental",
"templateLink": {
"uri": "[variables('applyRbacUrl')]",
"contentVersion": "1.0.0.0"
},
"parameters": {
"roleAssignmentId": {
"value": "[variables('roleAssignmentId')]"
},
"roleAssignmentsApiVersion": {
"value": "[variables('roleAssignmentsApiVersion')]"
},
"msiApiVersion": {
"value": "[variables('msiApiVersion')]"
},
"functionAppIdentityResourceId": {
"value": "[variables('functionAppIdentityResourceId')]"
},
"roleDefinitionId": {
"value": "[variables('roleDefinitionId')]"
}
}
}
}
],
"outputs": {
"getDefaultTokenEndpoint": {
"type": "string",
"value": "[reference('Microsoft.Resources/deployments/createFunctionApp', variables('deploymentsApiVersion')).outputs.getDefaultTokenEndpoint.value]"
},
"getAMSTokenEndpoint": {
"type": "string",
"value": "[reference('Microsoft.Resources/deployments/createFunctionApp', variables('deploymentsApiVersion')).outputs.getAMSTokenEndpoint.value]"
},
"getDefaultTokenEndpointWithDetails": {
"type": "string",
"value": "[reference('Microsoft.Resources/deployments/createFunctionApp', variables('deploymentsApiVersion')).outputs.getDefaultTokenEndpointWithDetails.value]"
},
"getAMSTokenEndpointWithDetails": {
"type": "string",
"value": "[reference('Microsoft.Resources/deployments/createFunctionApp', variables('deploymentsApiVersion')).outputs.getAMSTokenEndpointWithDetails.value]"
},
"functionTriggerUrl": {
"type": "string",
"value": "[reference('Microsoft.Resources/deployments/createFunctionApp', variables('deploymentsApiVersion')).outputs.functionTriggerUrl.value]"
},
"storageAccount": {
"type": "string",
"value": "[variables('storageAccountName')]"
},
"hostingPlanName": {
"type": "string",
"value": "[variables('hostingPlanName')]"
},
"functionAppIdentityResourceId": {
"type": "string",
"value": "[variables('functionAppIdentityResourceId')]"
},
"msiIdentity": {
"type": "object",
"value": "[reference('Microsoft.Resources/deployments/applyRbac', variables('deploymentsApiVersion')).outputs.msiIdentity.value]"
}
}
}