Public/PaaS/web/New-CmAzPaasWeb.json

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "WebAppName": {
            "defaultValue": "CmAzWebApp",
            "minLength": 2,
            "type": "String",
            "metadata": {
                "description": "Base name of the resource such as web app name and app service plan "
            }
        },
        "Sku": {
            "defaultValue": "F1",
            "allowedValues": [
                "F1",
                "D1",
                "B1",
                "B2",
                "B3",
                "S1",
                "S2",
                "S3",
                "P1",
                "P2",
                "P3",
                "P4"
            ],
            "type": "String",
            "metadata": {
                "description": "The SKU of App Service Plan "
            }
        },
        "LinuxFxVersion": {
            "defaultValue": "",
            "type": "String",
            "metadata": {
                "description": "The Runtime stack of current web app"
            }
        },
        "Location": {
            "defaultValue": "[resourceGroup().location]",
            "type": "String",
            "metadata": {
                "description": "Location for all resources."
            }
        },
        "Kind": {
            "defaultValue": "linux",
            "allowedValues": [
                "app",
                "linux"
            ],
            "type": "String",
            "metadata": {
                "description": "OS type."
            }
        },
        "SlotNames": {
            "defaultValue": [
                "production"
            ],
            "type": "Array"
        },
        "AppServicePlanName": {
            "type": "string"
        },
        "AppInstrumatationKey": {
            "defaultValue": "",
            "type": "string"
        },
        "ServiceContainer": {
            "type": "Object"
        }
    },
    "variables": {
        "webAppPortalName": "[parameters('WebAppName')]"
    },
    "resources": [
        {
            "type": "Microsoft.Web/serverfarms",
            "apiVersion": "2018-02-01",
            "name": "[parameters('AppServicePlanName')]",
            "location": "[parameters('Location')]",
            "sku": {
                "name": "[parameters('Sku')]"
            },
            "kind": "[parameters('Kind')]",
            "tags": {
                "cm-service": "[parameters('ServiceContainer').appServicePlan]"
            },
            "properties": {
                "reserved": true
            }
        },
        {
            "type": "Microsoft.Web/sites",
            "apiVersion": "2019-08-01",
            "name": "[variables('webAppPortalName')]",
            "location": "[parameters('Location')]",
            "dependsOn": [
                "[resourceId('Microsoft.Web/serverfarms', parameters('AppServicePlanName'))]"
            ],
            "kind": "app",
            "tags": {
                "cm-service": "[parameters('ServiceContainer').webapp]"
            },
            "properties": {
                "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('AppServicePlanName'))]",
                "siteConfig": {
                    "linuxFxVersion": "[parameters('LinuxFxVersion')]",
                    "appSettings": [
                        {
                            "name": "APPINSIGHTS_INSTRUMENTATIONKEY",
                            "value": "[if(equals(parameters('AppInstrumatationKey'), 'none'), json('null'), array(parameters('AppInstrumatationKey')))]"
                        },
                        {
                            "name": "APPLICATIONINSIGHTS_CONNECTION_STRING",
                            "value": "[if(equals(parameters('AppInstrumatationKey'), 'none'), json('null'), concat('InstrumentationKey=', parameters('AppInstrumatationKey')))]"
                        },
                        {
                            "name": "ApplicationInsightsAgent_EXTENSION_VERSION",
                            "value": "[if(equals(parameters('AppInstrumatationKey'), 'none'), json('null'), '~2')]"
                        }
                    ]
                }
            }
        },
        {
            "type": "Microsoft.Web/sites/slots",
            "apiVersion": "2019-08-01",
            "name": "[concat(variables('webAppPortalName'), '/', parameters('SlotNames')[copyIndex('SlotCopy')].name)]",
            "tags": {
                "cm-service": "[parameters('SlotNames')[copyIndex('SlotCopy')].service.publish.slot]"
            },
            "location": "[parameters('Location')]",
            "dependsOn": [
                "[resourceId('Microsoft.Web/Sites', variables('webAppPortalName'))]"
            ],
            "properties": {
            },
            "resources": [],
            "copy": {
                "name": "SlotCopy",
                "count": "[length(parameters('SlotNames'))]",
                "mode": "Parallel"
            }
        }
    ]
}