-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRemove-TempDeployApp.ps1
More file actions
45 lines (35 loc) · 1.41 KB
/
Copy pathRemove-TempDeployApp.ps1
File metadata and controls
45 lines (35 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# Now uses Get-AzureRMWebApp(Slot) and Set-AzureRmWebApp(Slot) to remove Virtual Directory from existing configuration
#Retrieve variables from environment and bail if not set
if (-not $Env:RESOURCEGROUPNAME)
{
Write-Error ("RESOURCEGROUPNAME environment variable is missing.")
exit 1
}
elseif (-not $Env:WEBSITENAME)
{
Write-Error ("WEBSITENAME environment variable is missing.")
exit 1
}
$resourceGroupName = "$Env:RESOURCEGROUPNAME"
$websiteName = "$Env:WEBSITENAME"
$slotName = if ($env:SLOTNAME) { $env:SLOTNAME } else { "NoSlot" }
$WebAppApiVersion = "2018-02-01"
Write-Host "Remove a virtual application"
# Retrieve Web App
$website = Get-AzureRmWebApp -Name $env:WEBSITENAME -ResourceGroupName $env:RESOURCEGROUPNAME
if($slotName -eq "NoSlot" )
{
write-Host "Configuring root web app"
$TempApp = $website.SiteConfig.VirtualApplications |? {$_.VirtualPath -eq "/tempdeploy"}
$null = $website.SiteConfig.VirtualApplications.Remove($TempApp);
$website | Set-AzureRmWebApp
}
else
{
write-Host "Configuring deployment slot: $slotName"
#Retrieve slot from main web app
$slotsite = Get-AzureRmWebAppSlot -WebApp $website -Slot $slotName
$TempApp = $slotsite.SiteConfig.VirtualApplications |? {$_.VirtualPath -eq "/tempdeploy"}
$null = $slotsite.SiteConfig.VirtualApplications.Remove($TempApp)
$slotsite | Set-AzureRmWebAppSlot
}