Is it easy to copy application settings from one web application to another on azure

I was wondering if there is an easy way to completely copy all the key values โ€‹โ€‹from one application of the application to the application, as shown in the figure below. I have a lot of these key values โ€‹โ€‹and have to do it manually every time is very cumbersome.

enter image description here

+6
source share
2 answers

You can use Azure PowerShell. Here is the PowerShell Script.

try{ $acct = Get-AzureRmSubscription } catch{ Login-AzureRmAccount } $myResourceGroup = '<your resource group>' $mySite = '<your web app>' $myResourceGroup2 = '<another resource group>' $mySite2 = '<another web app>' $props = (Invoke-AzureRmResourceAction -ResourceGroupName $myResourceGroup ` -ResourceType Microsoft.Web/sites/Config -Name $mySite/appsettings ` -Action list -ApiVersion 2015-08-01 -Force).Properties $hash = @{} $props | Get-Member -MemberType NoteProperty | % { $hash[$_.Name] = $props.($_.Name) } Set-AzureRMWebApp -ResourceGroupName $myResourceGroup2 ` -Name $mySite2 -AppSettings $hash 

This Script copy application settings from $mySite to $mySite2 . If your web application is associated with a slot, for $props you should use the following command.

 $props = (Invoke-AzureRmResourceAction -ResourceGroupName $myResourceGroup ` -ResourceType Microsoft.Web/sites/slots/Config -Name $mySite/$slot/appsettings ` -Action list -ApiVersion 2015-08-01 -Force).Properties 

And use Set-AzureRMWebAppSlot instead of Set-AzureRMWebApp

 Set-AzureRMWebAppSlot -ResourceGroupName $myResourceGroup2 ` -Name $mySite2 -Slot $slot -AppSettings $hash 
+7
source

There seems to be no way to give SetAzureRmWebAppSlot order of settings, which means a useless pile of garbage. Fortunately, there is another kind of cloud shell.

 srcResourceGroup=$1 srcName=$2 dstResourceGroup=$3 dstName=$4 settingsToBeRemoved=$(az webapp config appsettings list --resource-group $dstResourceGroup --name $dstName | jq '.[] | .name' -r) if [[ ! -z $settingsToBeRemoved ]]; then az webapp config appsettings delete --resource-group $dstResourceGroup --name $dstName --setting-names $settingsToBeRemoved > /dev/null fi settingsToBeCopied=$(az webapp config appsettings list --resource-group $srcResourceGroup --name $srcName | jq '.[] | .name+"="+.value' -r) if [[ ! -z $settingsToBeCopied ]]; then az webapp config appsettings set --resource-group $dstResourceGroup --name $dstName --settings $settingsToBeCopied > /dev/null fi echo "Copied settings from $srcName to $dstName." 
0
source

All Articles