Skip to content

Instantly share code, notes, and snippets.

@renzors
Last active January 7, 2019 21:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save renzors/167fc2aa8d2d5162563719ed1339a646 to your computer and use it in GitHub Desktop.
Save renzors/167fc2aa8d2d5162563719ed1339a646 to your computer and use it in GitHub Desktop.
This template has an Appservice plan + App Insights + Webapp (with app inshights extension and hybrid connection) + Slot (with app inshights extension and hybrid connection)
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"appServiceName": {
"type": "string",
"minLength": 1
},
"webAppName": {
"type": "string",
"minLength": 1
},
"stagingSlotName": {
"type": "string",
"minLength": 1
},
"appInsightsName": {
"type": "string",
"minLength": 1
},
"hybridConnectionName":{
"type": "string",
"minLength": 1
},
"relayName":{
"type": "string",
"minLength": 1
},
"relayResourceGroupName":{
"type": "string",
"minLength": 1
},
"skuService": {
"type": "string",
"minLength": 1,
"defaultValue": "S1"
}
},
"variables": {
"hybridConnectionResourceId": "[resourceId(parameters('relayResourceGroupName'), 'Microsoft.Relay/Namespaces/Hybridconnections', parameters('relayName'), parameters('hybridConnectionName'))]"
},
"resources": [
{
"type": "Microsoft.Web/serverfarms",
"apiVersion": "2016-09-01",
"name": "[parameters('appServiceName')]",
"location": "[resourceGroup().location]",
"sku": {
"name": "[parameters('skuService')]",
"capacity": 1
},
"tags": {
"displayName": "[parameters('appServiceName')]"
},
"properties": {
"name": "[parameters('appServiceName')]"
}
},
{
"apiVersion": "2014-04-01",
"name": "[parameters('appInsightsName')]",
"type": "Microsoft.Insights/components",
"location": "[resourceGroup().location]",
"tags": {
"[concat('hidden-link:', resourceGroup().id, '/providers/Microsoft.Web/sites/', parameters('webAppName'))]": "Resource",
"displayName": "AppInsightsComponent"
},
"properties": {
"applicationId": "[parameters('appInsightsName')]"
}
},
{
"name": "[parameters('webAppName')]",
"type": "Microsoft.Web/sites",
"location": "[resourceGroup().location]",
"apiVersion": "2015-08-01",
"dependsOn": [
"[resourceId('Microsoft.Web/serverfarms', parameters('appServiceName'))]"
],
"tags": {
"[concat('hidden-related:', resourceId('Microsoft.Web/serverfarms', parameters('appServiceName')))]": "Resource",
"displayName": "webApp"
},
"properties": {
"name": "[parameters('webAppName')]",
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('appServiceName'))]",
"siteConfig": {
"AlwaysOn": true,
"use32BitWorkerProcess": false
}
},
"resources": [
{
"apiVersion": "2015-08-01",
"name": "[parameters('stagingSlotName')]",
"type": "slots",
"tags": {
"displayName": "webAppSlots"
},
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.Web/Sites', parameters('webAppName'))]"
],
"properties": {
"siteConfig": {
"AlwaysOn": true,
"use32BitWorkerProcess": false
}
},
"resources": [
{
"apiVersion": "2016-08-01",
"name": "Microsoft.ApplicationInsights.AzureWebSites",
"type": "siteextensions",
"dependsOn": [
"[resourceId('Microsoft.Web/Sites/Slots', parameters('webAppName'), parameters('stagingSlotName'))]"
],
"properties": {
}
},
{
"apiVersion": "2018-02-01",
"name": "[concat(parameters('relayName'), '/', parameters('hybridConnectionName'))]",
"type": "hybridConnectionNamespaces/relays",
"location" : "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.Web/Sites/Slots', parameters('webAppName'), parameters('stagingSlotName'))]"
],
"properties": {
"serviceBusNamespace": "[parameters('relayName')]",
"relayName": "[parameters('hybridConnectionName')]",
"relayArmUri": "[variables('hybridConnectionResourceId')]",
"hostName": "[split(json(reference(variables('hybridConnectionResourceId'), '2016-07-01').userMetadata)[0].value, ':')[0]]",
"port": "[split(json(reference(variables('hybridConnectionResourceId'), '2016-07-01').userMetadata)[0].value, ':')[1]]",
"sendKeyName": "defaultSender",
"sendKeyValue": "[listkeys(concat(variables('hybridConnectionResourceId'), '/authorizationRules/defaultSender'), '2017-04-01').primaryKey]"
}
}
]
},
{
"apiVersion": "2015-08-01",
"name": "appsettings",
"type": "config",
"dependsOn": [
"[resourceId('Microsoft.Web/Sites', parameters('webAppName'))]",
"Microsoft.ApplicationInsights.AzureWebSites"
],
"properties": {
"APPINSIGHTS_INSTRUMENTATIONKEY": "[reference(concat('microsoft.insights/components/', parameters('appInsightsName'))).InstrumentationKey]"
}
},
{
"apiVersion": "2015-08-01",
"name": "slotconfignames",
"type": "config",
"dependsOn": [
"[resourceId('Microsoft.Web/Sites', parameters('webAppName'))]",
"appsettings"
],
"properties": {
"connectionStringNames": [ ],
"appSettingNames": [ "APPINSIGHTS_INSTRUMENTATIONKEY" ]
}
},
{
"apiVersion": "2015-08-01",
"name": "Microsoft.ApplicationInsights.AzureWebSites",
"type": "siteextensions",
"dependsOn": [
"[resourceId('Microsoft.Web/Sites', parameters('webAppName'))]"
],
"properties": {
}
},
{
"apiVersion": "2018-02-01",
"name": "[concat(parameters('relayName'), '/', parameters('hybridConnectionName'))]",
"type": "hybridConnectionNamespaces/relays",
"location" : "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.Web/Sites', parameters('webAppName'))]"
],
"properties": {
"serviceBusNamespace": "[parameters('relayName')]",
"relayName": "[parameters('hybridConnectionName')]",
"relayArmUri": "[variables('hybridConnectionResourceId')]",
"hostName": "[split(json(reference(variables('hybridConnectionResourceId'), '2016-07-01').userMetadata)[0].value, ':')[0]]",
"port": "[split(json(reference(variables('hybridConnectionResourceId'), '2016-07-01').userMetadata)[0].value, ':')[1]]",
"sendKeyName": "defaultSender",
"sendKeyValue": "[listkeys(concat(variables('hybridConnectionResourceId'), '/authorizationRules/defaultSender'), '2017-04-01').primaryKey]"
}
}
]
}
],
"outputs": {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment