1

When creating a new Slot for an Azure WebApp, how can I successfully change one or more of the AppSettings?

The docs for New-AzureRmWebAppSlot suggest that there is a parameter called -AppSettingsOverrides, but that does not work.

It should be noted however that the linked docs seem to incorrectly reference the New-AzureRmWebApp Cmdlet, so I can't be sure if the parameter is actually valid (although it seems to be accepted without error).

Here is the code that I am running.

New-AzureRmWebAppSlot -ResourceGroupName $resourceGroupName -Name $webAppName -Slot $slotName -AppSettingsOverrides @{"FUNCTION_APP_EDIT_MODE" = "readwrite"} -ErrorAction Stop

Has anyone else experienced this seemlying incorrect behaviour, and if so, how did you fix it?

My Azure version is 3.5.0.

David Gard
  • 8,944
  • 25
  • 89
  • 182

1 Answers1

3

You could create Slot firstly, then use Set-AzureRmWebAppSlot to change AppSetting. Following script works for me.

$myResourceGroup = "shuiapp"
$mySite = "shuicli"
$slotName = "Test1"
$webApp = Get-AzureRMWebAppSlot -ResourceGroupName $myResourceGroup -Name $mySite -Slot $slotName
$appSettingList = $webApp.SiteConfig.AppSettings

$hash = @{}
ForEach ($kvp in $appSettingList) {
    $hash[$kvp.Name] = $kvp.Value
}


$hash['ExistingKey2'] = "NewValue12"

Set-AzureRMWebAppSlot -ResourceGroupName $myResourceGroup -Name $mySite -AppSettings $hash -Slot $slotName

enter image description here

The question will be helpful.

Community
  • 1
  • 1
Shui shengbao
  • 17,120
  • 2
  • 21
  • 40
  • That should work. We use Octopus to deploy a Function App and step 2 is basically what you have proposed alreay, taking Octopus variables and adding/updating them. Obviously I'd prefer if things worked as described, but at least this is a fairly painless workaround. Thanks. – David Gard Sep 29 '17 at 12:43