有谁知道如何使用PowerShell将csv文件导入Azure应用程序设置(Web登台)?

时间:2017-11-28 22:30:19

标签: powershell csv azure azure-web-sites

这是我正在使用的代码。它在实时插槽上工作正常,但在暂存插槽上没有。

$csv = "C:\WorkDir\web-app-settings.csv"
$appSettingsList = Import-Csv $csv 
$resourcegroupname = "DevOp-Test-RG"
$name = "web-uks-staging"

$appSettingsHash = @{}
  Write-Host "current app settings" -foreground yellow;
  ForEach ($kvp in $appSettingsList) {
  $appSettingsHash[$kvp.Key] = $kvp.Value
  write-host $kvp.Key ": " $kvp.Value -foreground green;
Set-AzureRMWebApp -ResourceGroupName $resourcegroupname -Name $name -AppSettings $appSettingsHash

powershell中弹出的错误是资源下的“Set-AzureRMWebApp:资源'Microsoft.Web / sites / web-uks-staging' 没有找到'DevOp-Test-RG'组。“

我很感激帮助。非常感谢。

1 个答案:

答案 0 :(得分:1)

您应该使用Set-AzureRmWebAppSlot修改Azure Web App临时插槽。修改你的脚本如下:

$csv = "d:\webapp.csv"
$appSettingsList = Import-Csv $csv 
$resourcegroupname = "shuiapp"
$appname="shuicli"
$soltname = "shuisolt"

$appSettingsHash = @{}
  Write-Host "current app settings" -foreground yellow;
  ForEach ($kvp in $appSettingsList) {
  $appSettingsHash[$kvp.Key] = $kvp.Value
  write-host $kvp.Key ": " $kvp.Value -foreground green;

Set-AzureRmWebAppSlot -ResourceGroupName $resourcegroupname -Name $appname -Slot $soltname -AppSettings $appSettingsHash

}