{ "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { "appName": { "type": "string", "metadata": { "description": "Name of the instance of Azure App services to be created. This value should contain any spaces." } }, "skuName": { "type": "string", "defaultValue": "F1", "allowedValues": [ "F1", "D1", "B1", "B2", "B3", "S1", "S2", "S3", "P1", "P2", "P3", "P4" ], "metadata": { "description": "Describes plan's pricing tier and instance size. Check details at https://azure.microsoft.com/en-us/pricing/details/app-service/" } }, "appInsightsLocation": { "type": "string", "defaultValue": "South Central US", "allowedValues": [ "South Central US", "West Europe", "East US", "North Europe" ], "metadata": { "description": "Enter the application location." } }, "applicationId": { "type": "string", "metadata": { "description": "Identifier of the Azure AD application configured for the Partner Smart Office solutuion." } }, "authority": { "type": "string", "defaultValue": "https://login.microsoftonline.com/common", "metadata": { "description": "Address of the Azure AD authority used for portal authentication." } }, "repoUrl": { "type": "string", "defaultValue": "https://github.com/Microsoft/Partner-Smart-Office.git", "metadata": { "description": "Address of the repository containing the code to be deployed." } }, "branch": { "type": "string", "defaultValue": "master", "metadata": { "description": "Name of the branch to be deployed." } }, "storageAccountType": { "type": "string", "defaultValue": "Standard_LRS", "allowedValues": [ "Standard_LRS", "Standard_GRS", "Standard_RAGRS" ], "metadata": { "description": "Storage Account type" } } }, "variables": { "databaseAccountName": "[concat(uniquestring(resourceGroup().id), 'cosmosdb')]", "functionAppName": "[concat(uniquestring(resourceGroup().id), 'functions')]", "functionIdentityResourceId": "[concat(resourceId('Microsoft.Web/sites', variables('functionAppName')),'/providers/Microsoft.ManagedIdentity/Identities/default')]", "functionHostingPlanName": "[concat(uniquestring(resourceGroup().id), 'functions')]", "keyVaultName": "[concat('vault', uniquestring(resourceGroup().id))]", "storageAccountName": "[concat(uniquestring(resourceGroup().id), 'azfunctions')]", "storageAccountid": "[concat(resourceGroup().id,'/providers/','Microsoft.Storage/storageAccounts/', variables('storageAccountName'))]", "webAppIdentityResourceId": "[concat(resourceId('Microsoft.Web/sites', parameters('appName')),'/providers/Microsoft.ManagedIdentity/Identities/default')]", "webHostingPlanName": "[uniqueString(resourceGroup().id)]" }, "resources": [ { "apiVersion": "2014-04-01", "type": "microsoft.insights/components", "kind": "web", "name": "[parameters('appName')]", "location": "[parameters('appInsightsLocation')]", "tags": {}, "properties": { "ApplicationId": "[parameters('appName')]" }, "dependsOn": [] }, { "type": "Microsoft.DocumentDB/databaseAccounts", "kind": "GlobalDocumentDB", "name": "[variables('databaseAccountName')]", "apiVersion": "2015-04-08", "location": "[resourceGroup().location]", "tags": { "defaultExperience": "DocumentDB" }, "scale": null, "properties": { "databaseAccountOfferType": "Standard", "consistencyPolicy": { "defaultConsistencyLevel": "Session", "maxIntervalInSeconds": 5, "maxStalenessPrefix": 100 }, "name": "[variables('databaseAccountName')]" }, "dependsOn": [] }, { "type": "Microsoft.Storage/storageAccounts", "name": "[variables('storageAccountName')]", "apiVersion": "2016-12-01", "location": "[resourceGroup().location]", "kind": "Storage", "sku": { "name": "[parameters('storageAccountType')]" } }, { "type": "Microsoft.Web/serverfarms", "apiVersion": "2015-04-01", "name": "[variables('functionHostingPlanName')]", "location": "[resourceGroup().location]", "properties": { "name": "[variables('functionHostingPlanName')]", "computeMode": "Dynamic", "sku": "Dynamic" } }, { "apiVersion": "2016-08-01", "type": "Microsoft.Web/sites", "name": "[parameters('appName')]", "location": "[resourceGroup().location]", "identity": { "type": "SystemAssigned" }, "kind": "web", "dependsOn": [ "[concat('Microsoft.Insights/components/', parameters('appName'))]", "[resourceId('Microsoft.Web/serverfarms', variables('webHostingPlanName'))]" ], "properties": { "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('webHostingPlanName'))]", "siteConfig": { "appSettings": [ { "name": "ApplicationInsights:InstrumentationKey", "value": "[reference(concat('Microsoft.Insights/components/', parameters('appName'))).InstrumentationKey]" }, { "name": "Authentication:Authority", "value": "[parameters('authority')]" }, { "name": "Authentication:ClientId", "value": "[parameters('applicationId')]" }, { "name": "CosmosDbEndpoint", "value": "[reference(concat('Microsoft.DocumentDb/databaseAccounts/', variables('databaseAccountName'))).documentEndpoint]" }, { "name": "KeyVaultEndpoint", "value": "[concat('https://', variables('keyVaultName'), '.vault.azure.net')]" }, { "name": "PROJECT", "value": "src\\SmartOffice\\SmartOffice.csproj" }, { "name": "WEBSITE_NODE_DEFAULT_VERSION", "value": "6.9.1" } ] } }, "resources": [ { "apiVersion": "2015-08-01", "name": "web", "type": "sourcecontrols", "dependsOn": [ "[resourceId('Microsoft.Web/Sites', parameters('appName'))]" ], "properties": { "RepoUrl": "[parameters('repoURL')]", "branch": "[parameters('branch')]", "IsManualIntegration": true } } ] }, { "apiVersion": "2016-09-01", "name": "[variables('webHostingPlanName')]", "type": "Microsoft.Web/serverfarms", "location": "[resourceGroup().location]", "tags": { "displayName": "HostingPlan" }, "sku": { "name": "[parameters('skuName')]", "capacity": 1 }, "properties": { "name": "[variables('webHostingPlanName')]" } }, { "apiVersion": "2015-08-01", "type": "Microsoft.Web/sites", "name": "[variables('functionAppName')]", "location": "[resourceGroup().location]", "identity": { "type": "SystemAssigned" }, "kind": "functionapp", "dependsOn": [ "[concat('Microsoft.Insights/components/', parameters('appName'))]", "[resourceId('Microsoft.Web/serverfarms', variables('functionHostingPlanName'))]", "[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]" ], "properties": { "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('functionHostingPlanName'))]", "siteConfig": { "appSettings": [ { "name": "APPINSIGHTS_INSTRUMENTATIONKEY", "value": "[reference(concat('Microsoft.Insights/components/', parameters('appName'))).InstrumentationKey]" }, { "name": "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING", "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountid'),'2015-05-01-preview').key1)]" }, { "name": "FUNCTIONS_EXTENSION_VERSION", "value": "beta" }, { "name": "PROJECT", "value": "src\\SmartOffice.Functions\\SmartOffice.Functions.csproj" }, { "name": "WEBSITE_NODE_DEFAULT_VERSION", "value": "6.9.1" }, { "name": "ActiveDirectoryEndpoint", "value": "https://login.microsoftonline.com" }, { "name": "AzureWebJobsDashboard", "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountid'),'2015-05-01-preview').key1)]" }, { "name": "AzureWebJobsStorage", "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountid'),'2015-05-01-preview').key1)]" }, { "name": "CosmosDbEndpoint", "value": "[reference(concat('Microsoft.DocumentDb/databaseAccounts/', variables('databaseAccountName'))).documentEndpoint]" }, { "name": "KeyVaultEndpoint", "value": "[concat('https://', variables('keyVaultName'), '.vault.azure.net')]" }, { "name": "StorageConnectionString", "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountid'),'2015-05-01-preview').key1)]" } ] } }, "resources": [ { "apiVersion": "2015-08-01", "name": "web", "type": "sourcecontrols", "dependsOn": [ "[resourceId('Microsoft.Web/Sites', variables('functionAppName'))]" ], "properties": { "RepoUrl": "[parameters('repoURL')]", "branch": "[parameters('branch')]", "IsManualIntegration": true } } ] }, { "type": "Microsoft.KeyVault/vaults", "name": "[variables('keyVaultName')]", "apiVersion": "2015-06-01", "location": "[resourceGroup().location]", "tags": {}, "properties": { "sku": { "family": "A", "name": "premium" }, "tenantId": "[reference(variables('functionIdentityResourceId'), '2015-08-31-PREVIEW').tenantId]", "accessPolicies": [ { "tenantId": "[reference(variables('functionIdentityResourceId'), '2015-08-31-PREVIEW').tenantId]", "objectId": "[reference(variables('functionIdentityResourceId'), '2015-08-31-PREVIEW').principalId]", "permissions": { "secrets": [ "get" ] } }, { "tenantId": "[reference(variables('webAppIdentityResourceId'), '2015-08-31-PREVIEW').tenantId]", "objectId": "[reference(variables('webAppIdentityResourceId'), '2015-08-31-PREVIEW').principalId]", "permissions": { "secrets": [ "delete", "get", "list", "set" ] } } ], "enabledForDeployment": false }, "dependsOn": [ "[concat('Microsoft.Web/sites/', variables('functionAppName'))]" ] }, { "apiVersion": "2015-06-01", "type": "Microsoft.KeyVault/vaults/secrets", "name": "[concat(variables('keyVaultName'), '/', 'CosmosDbAccessKey')]", "properties": { "contentType": "text/plain", "value": "[listKeys(resourceId('Microsoft.DocumentDB/databaseAccounts', variables('databaseAccountName')), providers('Microsoft.DocumentDB', 'databaseAccounts').apiVersions[0]).primaryMasterKey]" }, "dependsOn": [ "[concat('Microsoft.DocumentDB/databaseAccounts/', variables('databaseAccountName'))]", "[concat('Microsoft.KeyVault/vaults/', variables('keyVaultName'))]" ] }, { "apiVersion": "2015-06-01", "type": "Microsoft.KeyVault/vaults/secrets", "name": "[concat(variables('keyVaultName'), '/', 'StorageConnectionString')]", "properties": { "contentType": "text/plain", "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountid'),'2015-05-01-preview').key1)]" }, "dependsOn": [ "[concat('Microsoft.KeyVault/vaults/', variables('keyVaultName'))]", "[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]" ] } ] }