{
    "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
          "websiteName": {
            "type": "string"
        },
                "hostingPlanName": {
            "type": "string"
	
        },
  "serverName": {
            "type": "string"
        },
        "databaseName": {
            "type": "string"
        },
        "administratorLogin": {
            "type": "string"
        },
        "administratorLoginPassword": {
            "type": "securestring"
        },
        "storageAccountType": {
          "type": "string",
          "defaultValue": "Standard_LRS",
          "allowedValues": [
            "Standard_LRS",
            "Standard_GRS",
            "Standard_ZRS"
          ],
          "metadata": {
            "description": "Storage Account type"
          }
        },
        "storageAccountName": {
            "type": "string"
        },
        "redisCacheName": {
          "type": "string"
        },
        "redisCacheSKU": {
          "type": "string",
          "allowedValues": [
            "Basic",
            "Standard"
          ],
          "defaultValue": "Standard",
          "metadata": {
            "description": "The pricing tier of the new Azure Redis Cache."
          }
        },
        "redisCacheFamily": {
          "type": "string",
          "defaultValue": "C",
          "metadata": {
            "description": "The family for the sku."
          }
        },
        "redisCacheCapacity": {
          "type": "int",
          "allowedValues": [
            0,
            1,
            2,
            3,
            4,
            5,
            6
          ],
          "defaultValue": 1,
          "metadata": {
            "description": "The size of the new Azure Redis Cache instance. "
          }
        },
        "redisCacheVersion": {
          "type": "string",
          "defaultValue": "2.8",
         "metadata": {
            "description": "The Redis server version of the new cache."
          }
        },
        "enableNonSslPort": {
          "type": "bool",
          "defaultValue": false,
          "metadata": {
            "description": "A boolean value that indicates whether to allow access via non-SSL ports."
          }
        },
        "diagnosticsStatus": {
          "type": "string",
          "defaultValue": "OFF",
          "allowedValues": [
                "ON",
                "OFF"
            ],
          "metadata": {
            "description": "A value that indicates whether diagnostices is enabled. Use ON or OFF."
          }
        },
        "hostingPlanSKUTier": {
          "type": "string"
        },
        "hostingPlanSKUName": {
          "type": "string"
        },
        "hostingPlanSKUCapacity": {
          "type": "int"
        },
        "databaseServiceLevel": {
          "type": "string"
        }
    },
    "variables": {
        "siteName": "[parameters('websiteName')]",
        "storageid": "[resourceId('Microsoft.Storage/storageAccounts',parameters('storageAccountName'))]",
        "cacheid": "[resourceId('Microsoft.Cache/Redis',parameters('redisCacheName'))]",
        "existingDiagnosticsStorageAccountName": "[parameters('storageAccountName')]"
    },
    "resources": [
        {
            "name": "[parameters('serverName')]",
            "type": "Microsoft.Sql/servers",
            "location": "[resourceGroup().location]",
            "apiVersion": "2014-04-01",
            "properties": {
                "administratorLogin": "[parameters('administratorLogin')]",
                "administratorLoginPassword": "[parameters('administratorLoginPassword')]",
                "version": "12.0"
            },
            "resources": [
                {
                    "name": "[parameters('databaseName')]",
                    "type": "databases",
                    "location": "[resourceGroup().location]",
                    "apiVersion": "2014-04-01",
                    "dependsOn": [
                        "[concat('Microsoft.Sql/servers/', parameters('serverName'))]"
                    ],
                    "properties": {
                         "edition": "Standard",
                        "collation": "SQL_Latin1_General_CP1_CI_AS",
                        "maxSizeBytes": "268435456000",
                        "requestedServiceObjectiveName": "[parameters('databaseServiceLevel')]",
                        "serviceLevelObjective":"[parameters('databaseServiceLevel')]"
                    }
                },
                {
                    "name": "AllowAllWindowsAzureIps",
                    "type": "firewallrules",
                    "location": "[resourceGroup().location]",
                    "apiVersion": "2014-04-01",
                    "dependsOn": [
                        "[concat('Microsoft.Sql/servers/', parameters('serverName'))]"
                    ],
                    "properties": {
                        "endIpAddress": "0.0.0.0",
                        "startIpAddress": "0.0.0.0"
                    }
                }
            ]
        },
        {
            "apiVersion": "2015-08-01",
            "type": "Microsoft.Web/serverfarms",
            "name": "[parameters('hostingPlanName')]",
            "location": "[resourceGroup().location]",
            "sku": {
                "tier": "[parameters('hostingPlanSKUTier')]",
                "name": "[parameters('hostingPlanSKUName')]",
                "capacity": "[parameters('hostingPlanSKUCapacity')]"
            },
            "properties": {
                "numberOfWorkers": 1
            }
        },
        {
          "type": "Microsoft.Storage/storageAccounts",
          "name": "[parameters('storageAccountName')]",
          "apiVersion": "2015-06-15",
          "location": "[resourceGroup().location]",
          "properties": {
            "accountType": "[parameters('storageAccountType')]"
          }
        },
        {
          "apiVersion": "2015-08-01",
          "name": "[parameters('redisCacheName')]",
          "type": "Microsoft.Cache/Redis",
          "location": "[resourceGroup().location]",
          "properties": {
            "enableNonSslPort": "[parameters('enableNonSslPort')]",
            "redisVersion": "[parameters('redisCacheVersion')]",
            "sku": {
              "capacity": "[parameters('redisCacheCapacity')]",
              "family": "[parameters('redisCacheFamily')]",
              "name": "[parameters('redisCacheSKU')]"
            },
            "minimumTlsVersion": "1.2"
          }
        },
        {
            "apiVersion": "2015-08-01",
            "name": "[variables('siteName')]",
            "type": "Microsoft.Web/sites",
            "location": "[resourceGroup().location]",
            "dependsOn": [
                "[concat('Microsoft.Web/serverFarms/', parameters('hostingPlanName'))]",
                "[concat('Microsoft.Storage/storageAccounts/', parameters('storageAccountName'))]"
            ],
            "properties": {
                "serverFarmId": "[parameters('hostingPlanName')]",               
                "siteConfig":{
                "alwaysOn": true,
                "appSettings": [
                        {
                            "name": "ClientId",
                            "value": "xxx"
                        },
                        {
                            "name": "ClientSecret",
                            "value": "xxx"
                        },
                        {
                            "name": "AzureTenantname",
                            "value": "xxx.onmicrosoft.com"
                        },
                        {
                            "name": "AzureADClientID",
                            "value": "xxx"
                        },
                        {
                            "name": "AzureADKey",
                            "value": "xxx"
                        },
                        {
                            "name": "AzureCacheEndpoint",
                            "value": "[concat(parameters('redisCacheName'), '.redis.cache.windows.net')]"
                        },
                        {
                            "name": "AzureCachePassword",
                            "value": "[listKeys(variables('cacheid'),'2015-08-01').primaryKey]"
                        },
                        {
                            "name": "SearchUsername",
                            "value": "xxx"
                        },
                        {
                            "name": "SearchPassword",
                            "value": "xxx"
                        },
                        {
                            "name": "TenantSiteUrl",
                            "value": "https://xxx.sharepoint.com"
                        },
                        {
                            "name": "AdminSiteUrl",
                            "value": "https://xxx-admin.sharepoint.com"
                        },
                        {
                            "name": "AppUrl",
                            "value":  "[concat('https://', toLower(variables('siteName')), '.azurewebsites.net/')]"
                        },
                         {
                            "name": "BlobUrl",
                            "value": "[concat('https://', parameters('storageAccountName'), '.blob.core.windows.net/wizdom365public/')]"
                        },
						{
							"name": "IOC:FAQ.BLL.Managers.IFaqManager, FAQ.BLL",
							"value": "FAQ.BLL.Managers.SQLFaqManager, FAQ.BLL"
						},
						{
							"name": "RedisCacheTlsProtocol",
							"value": "1.2"
						}
                    ],
                    "connectionStrings": [
                            {
                                "ConnectionString": "[concat('Data Source=tcp:', reference(concat('Microsoft.Sql/servers/', parameters('serverName'))).fullyQualifiedDomainName, ',1433;Initial Catalog=', parameters('databaseName'), ';User Id=', parameters('administratorLogin'), '@', parameters('serverName'), ';Password=', parameters('administratorLoginPassword'), ';Encrypt=True;TrustServerCertificate=False;')]",
                                "Name": "DefaultConnection",
                                "Type": 2
                            },
                            {
                                "ConnectionString": "[concat('DefaultEndpointsProtocol=https;AccountName=',parameters('storageAccountName'),';AccountKey=',listKeys(variables('storageid'),'2015-05-01-preview').key1)]",
                                "Name": "BlobStorageConnection",
                                "Type": 3
                            },
                            {
                                "ConnectionString": "[concat('metadata=res://*/DAL.WizdomModel.csdl|res://*/DAL.WizdomModel.ssdl|res://*/DAL.WizdomModel.msl;provider=System.Data.SqlClient;provider connection string=\"data source=', reference(concat('Microsoft.Sql/servers/', parameters('serverName'))).fullyQualifiedDomainName, ',1433;Initial Catalog=', parameters('databaseName'), ';User Id=', parameters('administratorLogin'), '@', parameters('serverName'), ';Password=', parameters('administratorLoginPassword'), ';Encrypt=True;Connection Timeout=30;multipleactiveresultsets=True;application name=EntityFramework\"')]",
                                "Name": "WizdomContainer",
                                "Type": 3
                            },
                            {
                                "ConnectionString": "[concat('metadata=res://*/BusinessAppDataModel.csdl|res://*/BusinessAppDataModel.ssdl|res://*/BusinessAppDataModel.msl;provider=System.Data.SqlClient;provider connection string=\"data source=', reference(concat('Microsoft.Sql/servers/', parameters('serverName'))).fullyQualifiedDomainName, ',1433;Initial Catalog=', parameters('databaseName'), ';User Id=', parameters('administratorLogin'), '@', parameters('serverName'), ';Password=', parameters('administratorLoginPassword'), ';Encrypt=True;Connection Timeout=30;multipleactiveresultsets=True;application name=EntityFramework\"')]",
                                "Name": "Wizdom365BusinessAppEntities",
                                "Type": 3
                            }

                        ]
                }
            }
        }
    ]
}