Skip to content

Instantly share code, notes, and snippets.

@ehrnst
Created March 4, 2020 17:00
Show Gist options
  • Select an option

  • Save ehrnst/f17f2e61ee3abd6e9598e2bbd34f9a32 to your computer and use it in GitHub Desktop.

Select an option

Save ehrnst/f17f2e61ee3abd6e9598e2bbd34f9a32 to your computer and use it in GitHub Desktop.
Deploy function app at subscription level
{
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
"contentVersion": "1.0.0.1",
"parameters": {
"resourceGroupName": {
"type": "string",
"metadata": {
"description": "Specify the name of the resource group"
}
},
"functionAppName": {
"type": "string",
"defaultValue": "[uniqueString(resourceGroup().id)]",
"metadata": {
"description": "Specify the name of the function application. Default value is to create a unique name"
}
},
"location": {
"type": "string",
"defaultValue": "[deployment().location]",
"metadata": {
"description": "Specify the location for the function application resources"
}
},
"ApplicationInsightsLocation": {
"type": "string",
"defaultValue": "West Europe",
"allowedValues": [
"North Europe",
"West Europe",
"Norway East"
],
"metadata": {
"description": "Specify the region for Application Insights data"
}
},
"runtimeStack": {
"type": "string",
"defaultValue": "powershell",
"allowedValues": [
"powershell",
"dotnet",
"node",
"java"
],
"metadata": {
"description": "Pick the language runtime that you want enabled"
}
},
"timezone": {
"type": "string",
"defaultValue": "UTC",
"metadata": {
"description": "Pick the timezone to use for the function"
}
}
},
"variables": {
"hostingPlanName": "[concat('plan', parameters('functionAppName'))]",
"storageAccountName": "[concat('str', parameters('functionappName'))]"
},
"resources": [
{
"type": "Microsoft.Resources/resourceGroups",
"apiVersion": "2018-05-01",
"location": "[parameters('location')]",
"name": "[parameters('resourceGroupName')]",
"properties": {
}
},
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2018-05-01",
"name": "function-db",
"resourceGroup": "[parameters('resourceGroupName')]",
"dependsOn": [
"[resourceId('Microsoft.Resources/resourceGroups/', parameters('resourceGroupName'))]"
],
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"variables": {},
"resources": [
{
"apiVersion": "2019-06-01",
"type": "Microsoft.Storage/storageAccounts",
"name": "[variables('storageAccountName')]",
"location": "[parameters('location')]",
"sku": {
"name": "Standard_LRS"
}
},
{
"name": "[parameters('functionAppName')]",
"type": "Microsoft.Web/sites",
"apiVersion": "2018-11-01",
"location": "[parameters('location')]",
"kind": "functionapp",
"dependsOn": [
"[resourceId('Microsoft.Web/serverfarms/', variables('hostingPlanName'))]",
"[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]",
"[resourceId('microsoft.insights/components/', parameters('functionAppName'))]"
],
"identity": {
"type": "SystemAssigned"
},
"properties": {
"siteConfig": {
"appSettings": [
{
"name": "COSMOSDB_CONNECTION_STRING",
"value": "[parameters('runtimeStack')]"
},
{
"name": "FUNCTIONS_WORKER_RUNTIME",
"value": "[parameters('runtimeStack')]"
},
{
"name": "AzureWebJobsStorage",
"value": "[concat('DefaultEndpointsProtocol=https;AccountName=',variables('storageAccountName'),';AccountKey=',listKeys(resourceId(subscription().subscriptionId, 'Microsoft.Storage/storageAccounts', variables('storageAccountName')), '2017-06-01').keys[0].value)]"
},
{
"name": "FUNCTIONS_EXTENSION_VERSION",
"value": "~2"
},
{
"name": "APPINSIGHTS_INSTRUMENTATIONKEY",
"value": "[resourceId(subscription().subscriptionId, parameters('functionAppName'), 'Microsoft.Insights/components', '2018-05-01-preview').InstrumentationKey]"
},
{
"name": "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING",
"value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(resourceId(subscription().subscriptionId, 'Microsoft.Storage/storageAccounts', variables('storageAccountName')),'2017-06-01').keys[0].value)]"
},
{
"name": "WEBSITE_CONTENTSHARE",
"value": "[toLower(parameters('functionAppName'))]"
},
{
"name": "WEBSITE_TIME_ZONE",
"value": "[parameters('timezone')]"
}
]
},
"name": "[parameters('functionAppName')]",
"clientAffinityEnabled": false,
"serverFarmId": "[variables('hostingPlanName')]"
}
},
{
"type": "Microsoft.Web/serverfarms",
"apiVersion": "2018-11-01",
"name": "[variables('hostingPlanName')]",
"location": "[parameters('location')]",
"properties": {
"name": "[variables('hostingPlanName')]"
},
"sku": {
"name": "Y1",
"tier": "Dynamic",
"size": "Y1",
"family": "Y",
"capacity": 0
}
},
{
"apiVersion": "2018-05-01-preview",
"name": "[parameters('functionAppName')]",
"type": "Microsoft.Insights/components",
"location": "[parameters('ApplicationInsightsLocation')]",
"tags": {
"[concat('hidden-link:', resourceId('Microsoft.Web/sites/', parameters('functionAppName')))]": "Resource"
},
"properties": {
"ApplicationId": "[parameters('functionAppName')]"
}
}
],
"outputs": {
"principalId": {
"type": "string",
"value": "[variables('hostingPlanName')]" //"[reference(resourceId('Microsoft.Web/sites', parameters('functionAppName')), '2018-11-01', 'Full').identity.principalId]"
}
}
}
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment