powershell update AppSettings

kumar 41 Reputation points
2022-01-11T06:08:19.48+00:00

I'm trying use below script to update the configuration settings. The script is getting executed successfully but the the new key values are not getting updated. Can you please help me

https://learn.microsoft.com/en-us/answers/questions/1564/adding-app-setting-to-existed-app-settings-in-web.html

Thanks

Windows for business | Windows Server | User experience | PowerShell
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
0 comments No comments
{count} votes

Answer accepted by question author
  1. Andriy Bilous 12,076 Reputation points MVP Volunteer Moderator
    2022-01-15T09:57:02.5+00:00

    Hello @kumar

    I used the script from your link and it is working as a charm.

    Here are my steps:

    • I added new AppSetting in my WebApp test1 = 2
      165326-image.png
    • I run the below script
        $webapp=Get-AzWebApp -ResourceGroupName test-rg  -Name testwabpp  
        $appSettings=$webapp.SiteConfig.AppSettings  
        $newAppSettings = @{}  
        ForEach ($item in $appSettings) {  
            $newAppSettings[$item.Name] = $item.Value  
        }  
        $newAppSettings['test1'] = "1"  
        Set-AzWebApp -ResourceGroupName test-rg  -Name testwabpp -AppSettings $newAppSettings  
      
    • App Setting test1 value is changed to 1
      165346-image.png
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.