0
votes

This is the code I am using. It works fine on live slots but not on staging slots.

$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

The error that pops up in powershell is "Set-AzureRMWebApp:The Resource 'Microsoft.Web/sites/web-uks-staging' under resource group 'DevOp-Test-RG' was not found."

I would appreciate the help a lot. Many thanks.

1
Also I have triple checked that the staging slot name is correct just to make sure there was no typo in powershell. - kev
Live slots do you mean web app? staging slots I think it is a deployment slot. You should use Set-AzureRmWebAppSlot to modify application settings. - Shui shengbao
Just checking in to see if the information provided was helpful. Please let me know if you would like further assistance. - Shui shengbao

1 Answers

1
votes

You should use Set-AzureRmWebAppSlot to modify an Azure Web App staging slot. Modify your script like below:

$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

}