Hi All, When deploying an Azure App Service is the...
# azure
m
Hi All, When deploying an Azure App Service is there any way to mark an APPSETTING as being a slot setting? At the moment all of my APPSETTINGS are swapping whenever I swap slots which is breaking things.
t
m
Hi @tall-librarian-49374. Yes I am. The App Setting only allows me to specify a name and value though, I can't see any way to specify that it should be tied to a Deployment Slot rather than swapped.
p
When I needed to do this a while back, I ended up using an ARM template deployment for the Sticky settings. I don't know if there is an out-of-box support for slot settings yet
it looks roughly like this:
Copy code
interface StickSettingsArgs {
    functionAppName: pulumi.Input<string>;
    hostingPlanName: pulumi.Input<string>;
    location: pulumi.Input<string>;
    resourceGroupName: pulumi.Input<string>;
    settings: string[];
}

class StickySettings extends pulumi.ComponentResource {
    constructor(name: string,
        args: StickSettingsArgs,
        opts: pulumi.ComponentResourceOptions = {}) {
        super("custom:appservice:StickyConfig", name, args, opts);
        const slotSettingsTemplate = {
            $schema: "<http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#>",
            contentVersion: "1.0.0.0",
            variables: {
                functionAppName: args.functionAppName,
                hostingPlanName: args.hostingPlanName,
                location: args.location
            },
            resources: [
                {
                    apiVersion: "2015-08-01",
                    name: "[variables('functionAppName')]",
                    type: "Microsoft.Web/sites",
                    location: "[variables('location')]",
                    properties: {
                        serverFarmId: "[variables('hostingPlanName')]"
                    },
                    resources: [
                        {
                            apiVersion: "2015-08-01",
                            name: "slotConfigNames",
                            type: "config",
                            dependsOn: [
                                "[resourceId('Microsoft.Web/sites', variables('functionAppName'))]"
                            ],
                            properties: {
                                appSettingNames: args.settings
                            }
                        },
                    ]
                }
            ]
        }
        const functionSlotConfigDeployment = new azure.core.TemplateDeployment(name, {
            resourceGroupName: args.resourceGroupName,
            name,
            templateBody: pulumi.output(slotSettingsTemplate).apply(JSON.stringify),
            deploymentMode: "Incremental",
        }, { parent: this });
        this.registerOutputs();
    }
}


// then used it like this
const stickyConfigSettings = new StickySettings("stickySlotConfig", {
    functionAppName: functionApp.name,
    hostingPlanName: config.appServicePlanName,
    location: resourceGroup.location,
    resourceGroupName: resourceGroup.name,
    settings: [an-array-of-the-sticky-app-settings-names]
});
m
Brilliant, thanks very much @plain-eye-9759
👍 1