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

前端 未结 3 782
既然无缘
既然无缘 2021-02-05 22:13

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 t

3条回答
  •  你的背包
    2021-02-05 22:38

    There appears to be no way to give SetAzureRmWebAppSlot the order of the settings, meaning it's a useless pile of garbage. Luckily, there's 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."
    

提交回复
热议问题