Skip to content

Instantly share code, notes, and snippets.

@tshallenberger
Created August 12, 2021 07:05
Show Gist options
  • Save tshallenberger/f2a3351993f165048e1553721cbcfd94 to your computer and use it in GitHub Desktop.
Save tshallenberger/f2a3351993f165048e1553721cbcfd94 to your computer and use it in GitHub Desktop.
An ARM template for deploying a containerized AppService, where the container resides in a resource group outside of your apps resource group (as is recommended by Azure).
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"webAppName": {
"type": "String"
},
"hostingPlanName": {
"type": "String"
},
"appInsightsLocation": {
"type": "String"
},
"sku": {
"defaultValue": "Standard",
"type": "String"
},
"registryName": {
"type": "String"
},
"imageName": {
"type": "String"
},
"registryResourceGroup": {
"type": "String"
},
"registryResourceId": {
"defaultValue": "[resourceId(subscription().subscriptionId, parameters('registryResourceGroup'), 'Microsoft.ContainerRegistry/registries', parameters('registryName'))]",
"type": "String"
},
"startupCommand": {
"defaultValue": "",
"type": "String"
}
},
"resources": [
{
"type": "Microsoft.Web/sites",
"name": "[parameters('webAppName')]",
"apiVersion": "2020-12-01",
"location": "[resourceGroup().location]",
"tags": {
"[concat('hidden-related:', '/subscriptions/', subscription().subscriptionId,'/resourcegroups/', resourceGroup().name, '/providers/Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]": "empty"
},
"properties": {
"name": "[parameters('webAppName')]",
"siteConfig": {
"appSettings": [
{
"name": "DOCKER_REGISTRY_SERVER_URL",
"value": "[reference(parameters('registryResourceId'), '2019-05-01').loginServer]"
},
{
"name": "DOCKER_REGISTRY_SERVER_USERNAME",
"value": "[listCredentials(parameters('registryResourceId'), '2019-05-01').username]"
},
{
"name": "DOCKER_REGISTRY_SERVER_PASSWORD",
"value": "[listCredentials(parameters('registryResourceId'), '2019-05-01').passwords[0].value]"
},
{
"name": "WEBSITES_ENABLE_APP_SERVICE_STORAGE",
"value": "false"
},
{
"name": "APPINSIGHTS_INSTRUMENTATIONKEY",
"value": "[reference(resourceId('microsoft.insights/components/', parameters('webAppName')), '2015-05-01').InstrumentationKey]"
}
],
"appCommandLine": "[parameters('startupCommand')]",
"linuxFxVersion": "[concat('DOCKER|', reference(parameters('registryResourceId'), '2019-05-01').loginServer, '/', parameters('imageName'))]"
},
"serverFarmId": "[concat('/subscriptions/', subscription().subscriptionId,'/resourcegroups/', resourceGroup().name, '/providers/Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]",
"hostingEnvironment": ""
},
"dependsOn": [
"[concat('Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]",
"[resourceId('microsoft.insights/components/', parameters('webAppName'))]"
]
},
{
"type": "Microsoft.Web/serverfarms",
"sku": {
"Tier": "[first(skip(split(parameters('sku'), ' '), 1))]",
"Name": "[first(split(parameters('sku'), ' '))]"
},
"kind": "linux",
"name": "[parameters('hostingPlanName')]",
"apiVersion": "2016-09-01",
"location": "[resourceGroup().location]",
"properties": {
"name": "[parameters('hostingPlanName')]",
"workerSizeId": "0",
"reserved": true,
"numberOfWorkers": "1",
"hostingEnvironment": ""
}
},
{
"type": "Microsoft.Insights/components",
"name": "[parameters('webAppName')]",
"apiVersion": "2014-04-01",
"location": "[parameters('appInsightsLocation')]",
"tags": {
"[concat('hidden-link:', resourceGroup().id, '/providers/Microsoft.Web/sites/', parameters('webAppName'))]": "Resource"
},
"properties": {
"applicationId": "[parameters('webAppName')]",
"Request_Source": "AzureTfsExtensionAzureProject"
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment