question

govindagoudpatil avatar image
0 Votes"
govindagoudpatil asked ryanchill answered

Adding app setting to existed app settings in web app

In order to add extra app setting to web app via powershell is there any way to added app setting without pulling down existed app setting and adding new one then updating back to web app.

I want to simply add new one as we do in portal via powershell.

Is there any other than below

 $webapp=Get-AzWebApp -ResourceGroupName $resourceGroupName  -Name $appName

 $appSettings=$webapp.SiteConfig.AppSettings
 $newAppSettings = @{}
 ForEach ($item in $appSettings) {
 $newAppSettings[$item.Name] = $item.Value
 }

 $newAppSettings['WEBSITE_RUN_FROM_PACKAGE'] = $urlToAppbinary

 Set-AzWebApp -ResourceGroupName $resourceGroupName -Name $appName  -AppSettings $newAppSettings
azure-webapps
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.

1 Answer

ryanchill avatar image
1 Vote"
ryanchill answered

Hi @govindagoudpatil,

The -AppSettings switch for PSSite works as a replace. Therefore, your above script is the proper way to add a setting. If you're doing this often, I would suggest converting into a custom cmdlet or function.

You can also submit feedback or create a new issue on the powershell github asking to create additional switches that will allow setting a specific value in the Hashtable.

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.