seems like a fairly simple task to do and I have numerous other examples where people have implemented it in the similar fashion. But somehow this doesnt work for me. Here is my script.
$webapp = Get-AzWebApp -Name $webappname -ResourceGroupName $resourcegroupName
$appset = $webapp.SiteConfig.AppSettings
$appset
$newsettings = new-object Microsoft.Azure.Management.WebSites.Models.NameValuePair
$newsettings.Name = "keyName"
$newsettings.Value = "MyValue"
$appset.Add($newsettings)
$newappset = @{}
$appset | ForEach-Object {
$newappset[$_.Name] = $_.Value
}
Set-AzWebApp -ResourceGroupName $resourcegroupName -Name $webappname -AppSettings $newappset
$webapp = Get-AzWebApp -Name $webappname -ResourceGroupName $resourcegroupName
Write-Output "New AppSettings:"
$webapp.SiteConfig.AppSettings
Both before/after gives the same set of configs and nothing changes when I check it on the Azure portal. I don't get any errors as well. Can anyone see what's wrong with the script.