是否可以轻松地将应用程序设置从一个Web应用程序复制到Azure上的另一个Web应用程序 [英] Is it possible to easily copy applications settings from one web app to another on azure

查看:91
本文介绍了是否可以轻松地将应用程序设置从一个Web应用程序复制到Azure上的另一个Web应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有一种简单的方法可以将所有键值从一个Web应用程序的应用程序设置完全复制到另一个应用程序中,如下图所示,我有很多这样的键值,并且每次都必须手动执行非常麻烦.

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.

推荐答案

您可以使用Azure PowerShell.这是适合您的PowerShell脚本.

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

此脚本将应用程序设置从$mySite复制到$mySite2.如果您的Web应用程序涉及插槽,则对于$props,您应该改用以下命令.

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 

然后,使用Set-AzureRMWebAppSlot代替Set-AzureRMWebApp

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

这篇关于是否可以轻松地将应用程序设置从一个Web应用程序复制到Azure上的另一个Web应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆