Azure Web App - Set App Settings
Octopus.AzurePowerShell exported 06/30/2020 by xtreampb belongs to 'Azure' category.
Sets the Azure web app settings of a targeted Azure web app deployment target. Will use the deployment slot if defined.
Note This template is designed to run against an azure web app octopus target Depends on Azure CLI and powershell to be installed on the worker
Parameters
When steps based on the template are included in a project's deployment process, the parameters below can be set.
Azure Account
An Azure account with permissions to the subscription and web app being modified
Web App Settings
The web app settings to append or update. Each new setting should be on a new line as a key value pair using the template key=value
Is Slot Settings
This is used to distinguish what settings are slot specific and which one are not. Slot setting do not follow the deployed app when the slot is swapped.
Script body
$webAppName = $OctopusParameters["Octopus.Action.Azure.WebAppName"]
$rg = $OctopusParameters["Octopus.Action.Azure.ResourceGroupName"]
$slot = $OctopusParameters["Octopus.Action.Azure.DeploymentSlot"]
$isSlotSettings = $OctopusParameters["azureWebAppSettings.isSlotSettings"]
$settingsType = "settings"
$appSettings = $OctopusParameters["azureWebAppSettings.settings"]
$settings = ""
Write-Host "Parsing Settings"
$appSettings -split "`n" | ForEach-Object { $settings += "$_ "}
$settings = $settings.TrimEnd(' ')
$cmdArgs = "--name $webAppName --resource-group $rg"
if(![string]::IsNullOrEmpty($slot))
{
if($isSlotSettings -eq 'true')
{
$settingsType = "slot-settings"
}
$settings += " --slot $slot"
}
$settingsArgs = " --$settingsType $settings"
Write-Host "Setting app settings"
$cmd = "az webapp config appsettings set $cmdArgs $settingsArgs"
write-verbose "command to execute: $cmd"
Invoke-Expression $cmd
To use this template in Octopus Deploy, copy the JSON below and paste it into the Library → Step templates → Import dialog.
Show JSON{
"Id": "850667b2-567d-46ba-a87d-d85dc31ebc83",
"Name": "Azure Web App - Set App Settings",
"Description": "Sets the Azure web app settings of a targeted Azure web app deployment target. Will use the deployment slot if defined.\n<hr />\n\n*<p>Note This template is designed to run against an azure web app octopus target</p>*\n*<p>Depends on Azure CLI and powershell to be installed on the worker</p>*",
"Version": 1,
"ExportedAt": "2020-06-30T15:48:06.905Z",
"ActionType": "Octopus.AzurePowerShell",
"Author": "xtreampb",
"Packages": [],
"Parameters": [
{
"Id": "598025e6-2d89-49bf-8abb-fda6da181de5",
"Name": "azureWebAppSettings.azAccount",
"Label": "Azure Account",
"HelpText": "An Azure account with permissions to the subscription and web app being modified",
"DefaultValue": "",
"DisplaySettings": {
"Octopus.ControlType": "AzureAccount"
}
},
{
"Id": "5d232cfd-8e9f-4b3e-8c4e-7bf3a75ced19",
"Name": "azureWebAppSettings.settings",
"Label": "Web App Settings",
"HelpText": "The web app settings to append or update. Each new setting should be on a new line as a key value pair using the template `key=value`",
"DefaultValue": "",
"DisplaySettings": {
"Octopus.ControlType": "MultiLineText"
}
},
{
"Id": "9bbee2cf-c57c-45db-8a7f-62a752779b56",
"Name": "azureWebAppSettings.isSlotSettings",
"Label": "Is Slot Settings",
"HelpText": "This is used to distinguish what settings are slot specific and which one are not. Slot setting do not follow the deployed app when the slot is swapped.",
"DefaultValue": "false",
"DisplaySettings": {
"Octopus.ControlType": "Checkbox"
}
}
],
"Properties": {
"Octopus.Action.Script.ScriptSource": "Inline",
"Octopus.Action.Script.Syntax": "PowerShell",
"Octopus.Action.Azure.AccountId": "#{azureWebAppSettings.azAccount}",
"Octopus.Action.Script.ScriptBody": "$webAppName = $OctopusParameters[\"Octopus.Action.Azure.WebAppName\"]\n$rg = $OctopusParameters[\"Octopus.Action.Azure.ResourceGroupName\"]\n$slot = $OctopusParameters[\"Octopus.Action.Azure.DeploymentSlot\"]\n$isSlotSettings = $OctopusParameters[\"azureWebAppSettings.isSlotSettings\"]\n\n$settingsType = \"settings\"\n\n$appSettings = $OctopusParameters[\"azureWebAppSettings.settings\"]\n\n$settings = \"\"\n\nWrite-Host \"Parsing Settings\"\n\n$appSettings -split \"`n\" | ForEach-Object { $settings += \"$_ \"}\n\n$settings = $settings.TrimEnd(' ')\n\n$cmdArgs = \"--name $webAppName --resource-group $rg\"\n\nif(![string]::IsNullOrEmpty($slot))\n{\n\tif($isSlotSettings -eq 'true')\n {\n \t$settingsType = \"slot-settings\"\n }\n \n\t$settings += \" --slot $slot\"\n}\n\n$settingsArgs = \" --$settingsType $settings\"\n\nWrite-Host \"Setting app settings\"\n\n$cmd = \"az webapp config appsettings set $cmdArgs $settingsArgs\"\n\nwrite-verbose \"command to execute: $cmd\"\n\nInvoke-Expression $cmd\n"
},
"Category": "Azure",
"HistoryUrl": "https://github.com/OctopusDeploy/Library/commits/master/step-templates/azure-web-app-set-app-settings.json",
"Website": "/step-templates/850667b2-567d-46ba-a87d-d85dc31ebc83",
"Logo": "iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAMAAACahl6sAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADNQTFRF////AHjXf7vrv931QJrh7/f8EIDaIIncMJHfYKvmz+b3n8zw3+76j8Ttr9XycLPpUKLkkKvYFAAABGZJREFUeNrsnNmCqjoQRc1MEiD8/9cer7Yt2KBJZQC8ez07sKlKTQlcLgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAzoUSnt8YxXlFuGHSbIaxvj+fip4btkLn1blkWLaF5v03yLhLOYlVuGYfMOMZzNGxCOzhjTJqFkXnjq3Dr1yyvPI3hGl3Ih3zzHHNKudRstRhX5O58vIcShY67Gq6EPIESlzUWvazaGAOGbvU7ArDu/g8M4o8opDZWvbvPzlL/MMBE8jT9T9W7PbAJlHPTBFRf9yVTEcs63msXz2UHLSgf650G/d5t+wjbxxB2UCMqGrk8/LFSD7uJMeNt5bcJCyQZyAe5Fo9KYfWS2flQrr4b4tpuzaeWjYs49rt9LHf9uZD7+VbyVi9EBNrjYjuq2sxQOrl+p+HuBVu45qvqfq691ttYFQ5KyKbyJgaIY/NGxrlWZwlwGvmvu1oY3PuAv0niTq6tZ78jk//9uc1r1r4lQki7y7sp2Tu4V1y2iLoqFTqi1lIGcpFiebrZNZ1dOkF0cCIlO8jQ47nCkam9Lilz9GhDF1I6XGLzfnhwDIIZVfI7+8SSgfHsijqXENOGJF5QorG4EcW0OrScqX/dDr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