Reputation: 43
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.
Upvotes: 0
Views: 461
Reputation: 19223
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
}
Upvotes: 1