Skip to content

Commit 5fed746

Browse files
Kotasudhakarreddydingmeng-xue
authored andcommitted
#12015 Set-AzWebAppSlot incorrectly formats serverFarmId causing Service Plan not found error (#12193)
* Git #11895 and #5983 * Fix for #12015- Set-AzWebAppSlot incorrectly formats serverFarmId causing Service Plan not found error * Updated ChangeLog.md * Fix for #12015- Set-AzWebAppSlot incorrectly formats serverFarmId causing Service Plan not found error
1 parent cd0e16a commit 5fed746

File tree

4 files changed

+4624
-1278
lines changed

4 files changed

+4624
-1278
lines changed

src/Websites/Websites.Test/ScenarioTests/WebAppSlotTests.ps1

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,13 +405,16 @@ function Test-SetWebAppSlot
405405
{
406406
# Setup
407407
$rgname = Get-ResourceGroupName
408+
$rgname1 = Get-ResourceGroupName
408409
$appname = Get-WebsiteName
409410
$location = Get-Location
410411
$slotname = "staging"
411412
$planName1 = Get-WebHostPlanName
412-
$planName2 = Get-WebHostPlanName
413+
$planName2 = Get-WebHostPlanName
414+
$planName3 = Get-WebHostPlanName
413415
$tier1 = "Standard"
414416
$tier2 = "Standard"
417+
$tier3 = "Standard"
415418
$apiversion = "2015-08-01"
416419
$resourceType = "Microsoft.Web/sites"
417420
$numberOfWorkers = 2
@@ -420,8 +423,10 @@ function Test-SetWebAppSlot
420423
{
421424
#Setup
422425
New-AzResourceGroup -Name $rgname -Location $location
426+
New-AzResourceGroup -Name $rgname1 -Location $location
423427
$serverFarm1 = New-AzAppServicePlan -ResourceGroupName $rgname -Name $planName1 -Location $location -Tier $tier1
424428
$serverFarm2 = New-AzAppServicePlan -ResourceGroupName $rgname -Name $planName2 -Location $location -Tier $tier2
429+
$serverFarm3 = New-AzAppServicePlan -ResourceGroupName $rgname1 -Name $planName3 -Location $location -Tier $tier3
425430

426431
# Create new web app
427432
$webApp = New-AzWebApp -ResourceGroupName $rgname -Name $appname -Location $location -AppServicePlan $planName1
@@ -495,6 +500,45 @@ function Test-SetWebAppSlot
495500
}
496501

497502
Assert-AreEqual $numberOfWorkers $slot.SiteConfig.NumberOfWorkers
503+
504+
#Set-AzWebAppSlot errors on operations for App Services not in the same resource group as the App Service Plan
505+
#setup
506+
507+
$app1 = Get-WebsiteName
508+
509+
# Create new web app
510+
$webApp = New-AzWebApp -ResourceGroupName $rgname1 -Name $app1 -Location $location -AppServicePlan $planName3
511+
512+
# Assert
513+
Assert-AreEqual $app1 $webApp.Name
514+
515+
# Create deployment slot
516+
$slot = New-AzWebAppSlot -ResourceGroupName $rgname1 -Name $app1 -Slot $slotname -AppServicePlan $planName3
517+
$appWithSlotName = "$app1/$slotname"
518+
519+
# Assert
520+
Assert-AreEqual $appWithSlotName $slot.Name
521+
Assert-Null $webApp.Identity
522+
Assert-AreEqual "AllAllowed" $slot.SiteConfig.FtpsState
523+
524+
# Get the deployment slot
525+
526+
$slot = Get-AzWebAppSlot -ResourceGroupName $rgname1 -Name $app1 -Slot $slotName
527+
528+
# Set config properties
529+
$slot.SiteConfig.HttpLoggingEnabled = $true
530+
$slot.SiteConfig.RequestTracingEnabled = $true
531+
$slot.SiteConfig.FtpsState = "FtpsOnly"
532+
$slot.SiteConfig.MinTlsVersion = "1.0"
533+
534+
$slot = $slot | Set-AzWebAppSlot
535+
536+
# Assert
537+
Assert-AreEqual $appWithSlotName $slot.Name
538+
Assert-AreEqual $true $slot.SiteConfig.HttpLoggingEnabled
539+
Assert-AreEqual $true $slot.SiteConfig.RequestTracingEnabled
540+
Assert-AreEqual "FtpsOnly" $slot.SiteConfig.FtpsState
541+
Assert-AreEqual "1.0" $slot.SiteConfig.MinTlsVersion
498542
}
499543
finally
500544
{
@@ -504,6 +548,7 @@ function Test-SetWebAppSlot
504548
Remove-AzAppServicePlan -ResourceGroupName $rgname -Name $planName1 -Force
505549
Remove-AzAppServicePlan -ResourceGroupName $rgname -Name $planName2 -Force
506550
Remove-AzResourceGroup -Name $rgname -Force
551+
Remove-AzResourceGroup -Name $rgname1 -Force
507552
}
508553
}
509554

src/Websites/Websites.Test/SessionRecords/Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebAppSlotTests/TestSetWebAppSlot.json

Lines changed: 4576 additions & 1276 deletions
Large diffs are not rendered by default.

src/Websites/Websites/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
* Fixed bug to get SiteConfig when -Name is not given for Get-AzWebApp
2727
* Added a support to create ASP for Linux Apps
2828
* Added exceptions for clone across resource groups
29+
* Added support to perform operations for Slots not in the same resource group as the App Service Plan
2930

3031
## Version 1.9.0
3132
* Fixed typo on help of `Update-AzWebAppAccessRestrictionConfig`.

src/Websites/Websites/Cmdlets/DeploymentSlots/SetAzureWebAppSlot.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ public override void ExecuteCmdlet()
317317

318318
CmdletHelpers.TryParseAppServicePlanMetadataFromResourceId(WebApp.ServerFarmId, out rg, out servicePlanName);
319319
WebApp.AzureStoragePath = null; // the API to update site Object doesn't have the AzureStorage Path property
320-
WebsitesClient.UpdateWebApp(ResourceGroupName, location, Name, Slot, servicePlanName, WebApp);
320+
WebsitesClient.UpdateWebApp(ResourceGroupName, location, Name, Slot, servicePlanName, WebApp,rg);
321321
WebsitesClient.AddCustomHostNames(ResourceGroupName, location, Name, WebApp.HostNames.ToArray(), Slot);
322322
break;
323323
}

0 commit comments

Comments
 (0)