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."
            }
        },
        "StagingSlotName": {
            "defaultValue": [
                "production"
            ],
            "type": "Array"
        },
        "AppServicePlanName": {
            "type": "string"
        },
        "AppInstrumatationKey": {
            "defaultValue": "",
            "type": "string"
        }
    },
    "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')]",
            "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",
            "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('StagingSlotName')[copyIndex()])]",
            "location": "[parameters('Location')]",
            "dependsOn": [
                "[resourceId('Microsoft.Web/Sites', variables('webAppPortalName'))]"
            ],
            "properties": {
            },
            "resources": [],
            "copy": {
                "name": "StagingSlotCopy",
                "count": "[length(parameters('StagingSlotName'))]",
                "mode": "Parallel"
            }
        }
    ]
}