Guest User

ARM Template

a guest
Oct 9th, 2019
4,409
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 11.19 KB | None | 0 0
  1. {
  2.   "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  3.   "contentVersion": "1.0.0.0",
  4.   "parameters": {
  5.     "functionName": {
  6.       "type": "string"
  7.     },
  8.     "keyVaultName": {
  9.       "type": "string"
  10.     },
  11.     "appInsightsName": {
  12.       "type": "string"
  13.     },
  14.     "storageAccName": {
  15.       "type": "string"
  16.     },
  17.     "sqlAdministratorLogin": {
  18.       "type": "string"
  19.     },
  20.     "sqlAdministratorPassword": {
  21.       "type": "string"
  22.     },
  23.     "sqlServerName": {
  24.       "type": "string"
  25.     },
  26.     "databaseName": {
  27.       "type": "string"
  28.     },
  29.     "userId": {
  30.       "type": "string"
  31.     },
  32.     "namingPrefix": {
  33.       "type": "string"
  34.     },
  35.     "resourceGroupLocation": {
  36.       "type": "string"
  37.     },
  38.     "appSettings": {
  39.       "type": "object"
  40.     }
  41.   },
  42.   "variables": {
  43.     "planName": "[replace(concat(parameters('resourceGroupLocation'), 'Plan'),' ','')]",
  44.     "functionName": "[concat(parameters('namingPrefix'), '-', parameters('functionName'))]",
  45.     "functionStagingName": "staging", //function name automatically added to url
  46.     "keyVaultName": "[concat(parameters('namingPrefix'), '-', parameters('keyVaultName'))]",
  47.     "appInsightsName": "[concat(parameters('namingPrefix'), '-', parameters('appInsightsName'))]",
  48.     "storageAccName": "[toLower(concat(parameters('namingPrefix'), parameters('storageAccName')))]",
  49.     "sqlServerName": "[concat(parameters('namingPrefix'), '-', parameters('sqlServerName'))]",
  50.     "databaseName": "[concat(parameters('namingPrefix'), '-', parameters('databaseName'))]",
  51.     "staticAppSettings": {
  52.       "WEBSITE_NODE_DEFAULT_VERSION": "10.14.1",
  53.       "WEBSITE_RUN_FROM_PACKAGE": "1",
  54.       "FUNCTIONS_EXTENSION_VERSION": "~2",
  55.       "FUNCTIONS_WORKER_RUNTIME": "dotnet"
  56.     },
  57.     "completeAppSettings": "[union(variables('staticAppSettings'), parameters('appSettings'))]"
  58.  
  59.   },
  60.   "resources": [
  61.     {
  62.       "type": "microsoft.insights/components",
  63.       "apiVersion": "2015-05-01",
  64.       "name": "[variables('appInsightsName')]",
  65.       "location": "[ResourceGroup().location]",
  66.       "kind": "web",
  67.       "properties": {
  68.         "Application_Type": "web",
  69.         "Request_Source": "IbizaWebAppExtensionCreate"
  70.       }
  71.     },
  72.     {
  73.       "type": "Microsoft.KeyVault/vaults",
  74.       "apiVersion": "2016-10-01",
  75.       "name": "[variables('keyVaultName')]",
  76.       "location": "[ResourceGroup().location]",
  77.       "properties": {
  78.         "sku": {
  79.           "family": "A",
  80.           "name": "Standard"
  81.         },
  82.         "tenantId": "[subscription().tenantId]",
  83.         "accessPolicies": [
  84.           {
  85.             "tenantId": "[subscription().tenantId]",
  86.             "objectId": "[parameters('userId')]",
  87.             "permissions": {
  88.               "keys": [
  89.                 "Get",
  90.                 "List",
  91.                 "Update",
  92.                 "Create",
  93.                 "Import",
  94.                 "Delete",
  95.                 "Recover",
  96.                 "Backup",
  97.                 "Restore"
  98.               ],
  99.               "secrets": [
  100.                 "Get",
  101.                 "List",
  102.                 "Set",
  103.                 "Delete",
  104.                 "Recover",
  105.                 "Backup",
  106.                 "Restore"
  107.               ],
  108.               "certificates": [
  109.                 "Get",
  110.                 "List",
  111.                 "Update",
  112.                 "Create",
  113.                 "Import",
  114.                 "Delete",
  115.                 "Recover",
  116.                 "Backup",
  117.                 "Restore",
  118.                 "ManageContacts",
  119.                 "ManageIssuers",
  120.                 "GetIssuers",
  121.                 "ListIssuers",
  122.                 "SetIssuers",
  123.                 "DeleteIssuers"
  124.               ]
  125.             }
  126.           }
  127.         ],
  128.         "enabledForDeployment": false,
  129.         "enabledForDiskEncryption": false,
  130.         "enabledForTemplateDeployment": false
  131.       }
  132.     },
  133.     {
  134.       "type": "Microsoft.KeyVault/vaults/accessPolicies",
  135.       "name": "[concat(variables('keyVaultName'),'/add')]",
  136.       "apiVersion": "2018-02-14",
  137.       "dependsOn": [
  138.         "[resourceId('Microsoft.Web/sites', variables('functionName'))]",
  139.         "[resourceId('Microsoft.KeyVault/vaults', variables('keyVaultName'))]"
  140.       ],
  141.       "properties": {
  142.         "accessPolicies": [
  143.           {
  144.             "tenantId": "[subscription().tenantId]",
  145.             "objectId": "[reference(concat(resourceId('Microsoft.Web/sites', variables('functionName')), '/providers/Microsoft.ManagedIdentity/Identities/default'), '2015-08-31-PREVIEW').principalId]",
  146.             "permissions": {
  147.               "keys": [
  148.               ],
  149.               "secrets": [
  150.                 "Get",
  151.                 "Set",
  152.                 "Delete"
  153.               ],
  154.               "certificates": [
  155.               ]
  156.             }
  157.           }
  158.         ]
  159.       }
  160.     },
  161.     {
  162.       "type": "Microsoft.Storage/storageAccounts",
  163.       "apiVersion": "2019-04-01",
  164.       "name": "[variables('storageAccName')]",
  165.       "location": "[ResourceGroup().location]",
  166.       "sku": {
  167.         "name": "Standard_LRS",
  168.         "tier": "Standard"
  169.       },
  170.       "kind": "Storage",
  171.       "properties": {
  172.         "networkAcls": {
  173.           "bypass": "AzureServices",
  174.           "virtualNetworkRules": [],
  175.           "ipRules": [],
  176.           "defaultAction": "Allow"
  177.         },
  178.         "supportsHttpsTrafficOnly": true,
  179.         "encryption": {
  180.           "services": {
  181.             "file": {
  182.               "enabled": true
  183.             },
  184.             "blob": {
  185.               "enabled": true
  186.             }
  187.           },
  188.           "keySource": "Microsoft.Storage"
  189.         }
  190.       }
  191.     },
  192.     {
  193.       "type": "Microsoft.Web/serverfarms",
  194.       "apiVersion": "2016-09-01",
  195.       "name": "[variables('planName')]",
  196.       "location": "[ResourceGroup().location]",
  197.       "sku": {
  198.         "name": "Y1",
  199.         "tier": "Dynamic",
  200.         "size": "Y1",
  201.         "family": "Y",
  202.         "capacity": 0
  203.       },
  204.       "kind": "functionapp",
  205.       "properties": {
  206.         "name": "[variables('planName')]",
  207.         "computeMode": "Dynamic",
  208.         "perSiteScaling": false,
  209.         "reserved": false,
  210.         "targetWorkerCount": 0,
  211.         "targetWorkerSizeId": 0
  212.       }
  213.     },
  214.     {
  215.       "type": "Microsoft.KeyVault/vaults/secrets",
  216.       "apiVersion": "2016-10-01",
  217.       "name": "[concat(variables('keyVaultName'), '/ExponeaPrivate')]",
  218.       "location": "northeurope",
  219.       "dependsOn": [
  220.         "[variables('keyVaultName')]"
  221.       ],
  222.       "properties": {
  223.         "value": "sample"
  224.       }
  225.     },
  226.     {
  227.       "type": "Microsoft.KeyVault/vaults/secrets",
  228.       "apiVersion": "2016-10-01",
  229.       "name": "[concat(variables('keyVaultName'), '/OTAccessToken')]",
  230.       "location": "northeurope",
  231.       "dependsOn": [
  232.         "[variables('keyVaultName')]"
  233.       ],
  234.       "properties": {
  235.         "value": "sample"
  236.       }
  237.     },
  238.     {
  239.       "type": "Microsoft.Sql/servers",
  240.       "apiVersion": "2015-05-01-preview",
  241.       "name": "[variables('sqlServerName')]",
  242.       "location": "[ResourceGroup().location]",
  243.       "properties": {
  244.         "administratorLogin": "[parameters('sqlAdministratorLogin')]",
  245.         "administratorLoginPassword": "[parameters('sqlAdministratorPassword')]",
  246.         "version": "12.0"
  247.       },
  248.       "resources": [
  249.         {
  250.           "apiVersion": "2017-10-01-preview",
  251.           "dependsOn": [
  252.             "[concat('Microsoft.Sql/servers/', variables('sqlServerName'))]"
  253.           ],
  254.           "location": "[ResourceGroup().location]",
  255.           "name": "[variables('databaseName')]",
  256.           "properties": {
  257.             "collation": "SQL_Latin1_General_CP1_CI_AS",
  258.             "maxSizeBytes": 104857600,
  259.             "sampleName": "",
  260.             "zoneRedundant": false,
  261.             "licenseType": "",
  262.             "readScale": "Disabled",
  263.             "readReplicaCount": 0,
  264.             "minCapacity": "",
  265.             "autoPauseDelay": ""
  266.           },
  267.           "sku": {
  268.             "name": "Basic",
  269.             "tier": "Basic"
  270.           },
  271.           "type": "databases"
  272.         },
  273.         {
  274.           "apiVersion": "2014-04-01-preview",
  275.           "dependsOn": [
  276.             "[concat('Microsoft.Sql/servers/', variables('sqlServerName'))]"
  277.           ],
  278.           "location": "[ResourceGroup().location]",
  279.           "name": "AllowAllWindowsAzureIps",
  280.           "properties": {
  281.             "endIpAddress": "0.0.0.0",
  282.             "startIpAddress": "0.0.0.0"
  283.           },
  284.           "type": "firewallrules"
  285.         }
  286.       ]
  287.     },
  288.     {
  289.       "type": "Microsoft.Web/sites",
  290.       "apiVersion": "2016-08-01",
  291.       "name": "[variables('functionName')]",
  292.       "location": "[ResourceGroup().location]",
  293.       "dependsOn": [
  294.         "[variables('planName')]",
  295.         "[variables('appInsightsName')]",
  296.         "[variables('storageAccName')]",
  297.         "[variables('keyVaultName')]",
  298.         "[variables('databaseName')]"
  299.       ],
  300.       "kind": "functionapp",
  301.       "identity": {
  302.         "type": "SystemAssigned"
  303.       },
  304.       "properties": {
  305.         "serverFarmId": "[variables('planName')]",
  306.         "enabled": true,
  307.         "reserved": false
  308.       },
  309.       "resources": [
  310.         {
  311.           "apiVersion": "2015-08-01",
  312.           "name": "connectionstrings",
  313.           "type": "config",
  314.           "dependsOn": [
  315.             "[variables('functionName')]",
  316.             "[variables('databaseName')]"
  317.           ],
  318.           "properties": {
  319.           }
  320.         },
  321.         {
  322.           "apiVersion": "2015-08-01",
  323.           "name": "appsettings",
  324.           "type": "config",
  325.           "dependsOn": [
  326.             "[variables('functionName')]",
  327.             "[variables('appInsightsName')]",
  328.             "[variables('storageAccName')]",
  329.             "[variables('keyVaultName')]"
  330.           ],
  331.           "properties": "[union(variables('completeAppSettings'),json(concat('{ AzureWebJobsStorage:\"', concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccName'), ';AccountKey=', listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccName')), '2019-04-01').keys[0].value), '\", WEBSITE_CONTENTAZUREFILECONNECTIONSTRING:\"',\tconcat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccName'), ';AccountKey=', listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccName')), '2019-04-01').keys[0].value), '\", WEBSITE_CONTENTSHARE:\"', variables('functionName'), '\", APPINSIGHTS_INSTRUMENTATIONKEY:\"', reference(concat('microsoft.insights/components/', variables('appInsightsName'))).InstrumentationKey, '\", KeyVaultUri:\"', reference(concat('Microsoft.KeyVault/vaults/', variables('keyVaultName'))).vaultUri, '\"}')))]"
  332.         },
  333.         {
  334.           "type": "slots",
  335.           "apiVersion": "2016-08-01",
  336.           "name": "[variables('functionStagingName')]",
  337.           "location": "[ResourceGroup().location]",
  338.           "dependsOn": [
  339.             "[variables('functionName')]",
  340.             "[variables('keyVaultName')]"
  341.           ],
  342.           "kind": "functionapp",
  343.           "properties": {
  344.             "enabled": false,
  345.             "serverFarmId": "[variables('planName')]"
  346.           }
  347.         }
  348.       ]
  349.     }
  350.   ]
  351. }
Advertisement
Add Comment
Please, Sign In to add comment