Adding app setting to existed app settings in web app

Govindagoud patil 21 Reputation points
2019-11-21T07:21:22.78+00:00

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 App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,957 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ryan Hill 28,731 Reputation points Microsoft Employee
    2019-11-25T02:01:48.473+00:00

    Hi @Govindagoud patil ,

    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.

    1 person found this answer helpful.
    0 comments No comments

Your answer

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