Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to easily copy applications settings from one web app to another on azure

I was wondering if there is an easy way to completely copy all the key values from one web app's application settings to another, as seen in the below picture I have a lot of these key values and having to do this manually every time is very cumbersome.

enter image description here

like image 695
Farhad-Taran Avatar asked Jan 31 '16 19:01

Farhad-Taran


People also ask

Can you clone an App Service Azure?

With the release of Microsoft Azure PowerShell version 1.1. 0, a new option has been added to New-AzWebApp that lets you clone an existing App Service app to a newly created app in a different region or in the same region.

How does Azure provide support for different web applications?

Azure App Service also supports deployments by using the Web Deploy technology. This approach is available with Visual Studio, WebMatrix, and Visual Studio Team Services. If you want to perform deployments by using Git or FTP, you must configure deployment credentials.

Is Web app and App Service same in Azure?

Azure runs App Services on a fully managed set of virtual machines in either a dedicated or shared mode, based on your App Service Plan. ... Web App – used for hosting websites and web applications (previously Azure Websites) API App – used for hosting the RESTful APIs. Not sure to understand the difference?


1 Answers

You can use Azure PowerShell. Here is a PowerShell Script for you.

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 app settings from $mySite to $mySite2. If your web app involves with slot, for $props, you should use the following command instead.

$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
like image 106
Jack Zeng Avatar answered Oct 17 '22 03:10

Jack Zeng