{ "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { "appName": { "type": "string", "metadata": { "description": "The name of the function app that you wish to create." } }, "sku": { "type": "string", "allowedValues": [ "Free", "Shared", "Basic", "Standard" ], "defaultValue": "Standard", "metadata": { "description": "The pricing tier for the hosting plan (if one is needed)." } }, "workerSize": { "type": "string", "allowedValues": [ "0", "1", "2" ], "defaultValue": "0", "metadata": { "description": "The instance size of the hosting plan (small, medium, or large), if one is needed." } }, "appServicePlanId": { "type": "string", "defaultValue": "null", "metadata": { "description": "Resource ID for the App Service Plan. If null, an App Service Plan will be created." } }, "storageAccountType": { "type": "string", "defaultValue": "Standard_LRS", "allowedValues": [ "Standard_LRS", "Standard_GRS", "Standard_RAGRS" ], "metadata": { "description": "Storage Account type" } } }, "variables": { "functionAppName": "[parameters('appName')]", "hostingPlanName": "[parameters('appName')]", "genPlanId": "[resourceId('Microsoft.Web/serverFarms/', variables('hostingPlanName'))]", "hostingPlanId": "[if(equals(parameters('appServicePlanId'),'null'), variables('genPlanId'), parameters('appServicePlanId'))]", "storageAccountName": "[concat(uniquestring(resourceGroup().id), 'functions')]" }, "resources": [ { "type": "Microsoft.Storage/storageAccounts", "name": "[variables('storageAccountName')]", "apiVersion": "2017-10-01", "location": "[resourceGroup().location]", "kind": "Storage", "sku": { "name": "[parameters('storageAccountType')]" } }, { "type": "Microsoft.Web/serverfarms", "apiVersion": "2016-09-01", "condition": "[equals(parameters('appServicePlanId'),'null')]", "name": "[variables('hostingPlanName')]", "location": "[resourceGroup().location]", "properties": { "name": "[variables('hostingPlanName')]", "sku": "[parameters('sku')]", "workerSize": "[parameters('workerSize')]", "hostingEnvironment": "", "numberOfWorkers": 1 } }, { "apiVersion": "2016-08-01", "type": "Microsoft.Web/sites", "name": "[variables('functionAppName')]", "location": "[resourceGroup().location]", "kind": "functionapp", "properties": { "name": "[variables('functionAppName')]", "serverFarmId": "[variables('hostingPlanId')]", "hostingEnvironment": "", "clientAffinityEnabled": false, "siteConfig": { "alwaysOn": true, "cors":{ "allowedOrigins":[ "https://functions.azure.com", "https://functions-staging.azure.com", "https://functions-next.azure.com", "https://functions-usgov-iowa.azurewebsites.us", "https://functions-usgov-texas.azurewebsites.us", "https://functions.ext.azure.us" ] } } }, "dependsOn": [ "[resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName'))]", "[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]" ], "resources": [ { "apiVersion": "2016-08-01", "name": "appsettings", "type": "config", "dependsOn": [ "[resourceId('Microsoft.Web/sites', variables('functionAppName'))]", "[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]" ], "properties": { "AzureWebJobsStorage": "[concat('DefaultEndpointsProtocol=https;AccountName=',variables('storageAccountName'),';AccountKey=',listkeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '2015-05-01-preview').key1,';')]", "AzureWebJobsDashboard": "[concat('DefaultEndpointsProtocol=https;AccountName=',variables('storageAccountName'),';AccountKey=',listkeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '2015-05-01-preview').key1,';')]", "FUNCTIONS_EXTENSION_VERSION": "~1" } } ] } ] }