Question

stilren on Fri, 24 Jan 2020 06:51:48


I am trying to lock some app settings for a specific slot using ARM templates. Is it possible using the latest AppService api version? Before you would use something like this.
{
    "apiVersion": "2015-08-01",
    "name": "slotconfignames",
    "type": "config",
    "dependsOn": [
        "[resourceId('Microsoft.Web/Sites', variables('siteName'))]"
    ],
    "properties": {
        "appSettingNames": [ "AppSettingKey1", "AppSettingKey2" ]
    }
}

Replies

SwathiDhanwada-MSFT on Fri, 31 Jan 2020 14:20:59


Thanks for reaching out! Here is a template which I tried for sticky slot settings and I hope it might help you in achieving your requirement.

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "environmentName": {
            "type": "string"
        },
        "siteLocation": {
            "type": "string",
            "allowedValues": [ "Central US", "East US" ],
            "defaultValue": "Central US"
        }
    },
    "variables": {
        "appServicePlanName": "[concat('demoserviceplan-', parameters('environmentName'))]",
        "siteName": "[concat('demosite-', parameters('environmentname'))]",
        "siteProperties": {
            
        }
    },
    "resources": [
        {
            "apiVersion": "2019-08-01",
            "name": "[variables('appServicePlanName')]",
            "type": "Microsoft.Web/serverfarms",
            "location": "[parameters('siteLocation')]",
            "sku": {
                "name": "S1",
                "tier": "Standard",
                "capacity": 1
            },
            "properties": {
                "name": "[variables('appServicePlanName')]"
            }
        },
        {
            "apiVersion": "2019-08-01",
            "name": "[variables('siteName')]",
            "type": "Microsoft.Web/sites",
            "location": "[parameters('siteLocation')]",
            "dependsOn": [
                "[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]"
            ],
            "properties": {
                "serverFarmId": "[variables('appServicePlanName')]"
            },
            "resources": [
                {
                    "apiVersion": "2019-08-01",
                    "name": "web",
                    "type": "config",
                    "dependsOn": [
                        "[resourceId('Microsoft.Web/Sites', variables('siteName'))]"
                    ],
                    "properties": {
                            "phpVersion": "5.6",
                            "netFrameworkVersion": "v4.0",
                            "use32BitWorkerProcess": true, 
                            "webSocketsEnabled": false,
                            "alwaysOn": false,
                            "requestTracingEnabled": false, 
                            "httpLoggingEnabled": false, 
                            "logsDirectorySizeLimit": 35,
                            "detailedErrorLoggingEnabled": false,
                            "remoteDebuggingEnabled": false,
                            "remoteDebuggingVersion": "VS2019",

                            "defaultDocuments": [
                                "Default.htm",
                                "Default.html",
                                "Default.asp",
                                "index.htm",
                                "index.html",
                                "iisstart.htm",
                                "default.aspx",
                                "index.php",
                                "hostingstart.html"
                            ]
                        }
                },
                {
                    "apiVersion": "2019-08-01",
                    "name": "appsettings",
                    "type": "config",
                    "dependsOn": [
                        "[resourceId('Microsoft.Web/Sites', variables('siteName'))]"
                    ],
                    "properties": {
                        "AppSettingKey1": "Some value",
                        "AppSettingKey2": "My second setting",
                        "AppSettingKey3": "My third setting",
                        "WEBSITE_TIME_ZONE": "Pacific Standard Time"
                    }
                },
                {
                    "apiVersion": "2019-08-01",
                    "name": "connectionstrings",
                    "type": "config",
                    "dependsOn": [
                        "[resourceId('Microsoft.Web/Sites', variables('siteName'))]"
                    ],
                    "properties": {
                        "ConnString1": {
                            "value": "My custom connection string",
                            "type": "Custom"
                        },
                        "ConnString2": {
                            "value": "My SQL connection string",
                            "type": "SQLAzure"
                        }
                    }
                },
                {
                    "apiVersion": "2019-08-01",
                    "name": "slotconfignames",
                    "type": "config",
                    "dependsOn": [
                        "[resourceId('Microsoft.Web/Sites', variables('siteName'))]"
                    ],
                    "properties": {
                        "connectionStringNames": [ "ConnString1" ],
                        "appSettingNames": [ "AppSettingKey1", "AppSettingKey2" ]
                    }
                },
                {
                    "apiVersion": "2019-08-01",
                    "name": "Staging",
                    "type": "slots",
                    "location": "[parameters('siteLocation')]",
                    "dependsOn": [
                        "[resourceId('Microsoft.Web/Sites', variables('siteName'))]"
                    ],
                    "properties": { },
                    "resources": [
                        {
                            "apiVersion": "2019-08-01",
                            "name": "web",
                            "type": "config",
                            "dependsOn": [
                                "[resourceId('Microsoft.Web/Sites/Slots', variables('siteName'), 'Staging')]"
                            ],
                            "properties": "[variables('siteProperties')]"
                        },
                        {
                            "apiVersion": "2019-08-01",
                            "name": "appsettings",
                            "type": "config",
                            "dependsOn": [
                                "[resourceId('Microsoft.Web/Sites/Slots', variables('siteName'), 'Staging')]"
                            ],
                            "properties": {
                                "AppSettingKey1": "Some staging value",
                                "AppSettingKey2": "My second staging setting",
                                "AppSettingKey3": "My third staging setting",
                                "WEBSITE_TIME_ZONE": "Pacific Standard Time"
                            }
                        },
                        {
                            "apiVersion": "2019-08-01",
                            "name": "connectionstrings",
                            "type": "config",
                            "dependsOn": [
                                "[resourceId('Microsoft.Web/Sites/Slots', variables('siteName'), 'Staging')]"
                            ],
                            "properties": {
                                "ConnString1": {
                                    "value": "My custom connection string",
                                    "type": "Custom"
                                },
                                "ConnString2": {
                                    "value": "My SQL connection string",
                                    "type": "SQLAzure"
                                }
                            }
                        }
                    ]
                }
            ]
        }
    ]
}

Hope this helps!