Azure, powershell

Copying Azure Appsettings between App services using powershell script

In a project lifecycle you are mostly dealing with a lot of servers, each representing a stage in your project cycle.

App services usually have app settings stored in Azure which makes it quite convenient for the admin to update them from Azure and not giving access to the values to a developer.

I always felt the pain of copying down appsettings from 1 App service to another on different servers so I wrote down this simple script which does the work for me.

 

 

$myResourceGroup = ‘RG-CRM-AE-PREPROD’

 

$mySite = ‘AT-CRM-UBIQUITY-AE-PP-01’

 

$webApp = Get-AzureRmWebApp -ResourceGroupName $myResourceGroup -Name $mySite

$appSettingList = $webApp.SiteConfig.AppSettings

 

$hash = @{}

ForEach ($kvp in $appSettingList) {

$hash[$kvp.Name] = $kvp.Value

}

 

$hash[‘NewKey’] = “NewValue”

$hash[‘ExistingKey’] = “NewValue”

 

Set-AzureRmWebApp -ResourceGroupName $myResourceGroup -Name $mySite -AppSettings $hash

 

Standard

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s