question

VarunMehta-3029 avatar image
0 Votes"
VarunMehta-3029 asked bhargaviannadevara-msft edited

Not able to update AppSettings for Azure App Service using PS cmdlet Set-AzWebApp

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.





azure-webapps
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@VarunMehta-3029 Hope the provided inputs help. Are there any further questions here?

0 Votes 0 ·
VarunMehta-3029 avatar image VarunMehta-3029 bhargaviannadevara-msft ·

Thanks for the update. I am all good now.

1 Vote 1 ·

1 Answer

bhargaviannadevara-msft avatar image
0 Votes"
bhargaviannadevara-msft answered

@VarunMehta-3029 Thanks for reaching out. This is certainly not an issue with your script, but with the Set-AzWebApp cmdlet itself.

There have been similar reports about this cmdlet from other customers that are being discussed on the Azure Powershell repository in: #14998, #15038 and #15078.

The fix for this issue has been rolled out and is available as part of the latest Az module versioned 6.0.0 having Az.Websites version 2.6.0.
And I can confirm that your script works alright with the latest Az module.

Please update the module on your machine with: Update-Module -Name Az, and let us know if you still see issues retrying setting AppSettings.

Hope this helps. Thanks again for your patience.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.