-
Notifications
You must be signed in to change notification settings - Fork 20
/
deployToAzureLIVE.ps1
54 lines (41 loc) · 2.31 KB
/
deployToAzureLIVE.ps1
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
46
47
48
49
50
51
52
53
54
$status = git status --porcelain
if ($status) { throw "There are uncommitted changes." }
az account set -s "<<your southwind subscription Id>>"
az acr login --name southwind
if(-Not $?){ Write-Host '"az acr login" failed' -ForegroundColor DarkRed; exit; }
Get-ChildItem -Path "Framework" -Recurse -Include "package.json","*.csproj" | Resolve-Path -Relative | tar -cf Framework.tar -T -
docker build -f ".\Southwind.Server\Dockerfile" . -t southwind-live
if(-Not $?){ Write-Host '"docker build" failed' -ForegroundColor DarkRed; exit; }
docker tag southwind-live southwind.azurecr.io/signum/southwind-live
docker push southwind.azurecr.io/signum/southwind-live
if(-Not $?){ Write-Host '"docker push" failed' -ForegroundColor DarkRed; exit; }
$appName = 'southwind-app-live'
$resourceGroup = 'southwind-live'
$slotName = 'behind'
$urlSlot = 'https://southwind-app-live-behind.azurewebsites.net/'
$url = 'https://southwind-app-live.azurewebsites.net/'
Write-Host '# STOP slot' $slotName -ForegroundColor DarkRed
az webapp stop --resource-group $resourceGroup --name $appName --slot $slotName
.\Framework\Utils\CheckUrl.exe dead $urlSlot
Write-Host
Write-Host '# SQL Migrations' -ForegroundColor Cyan
$env:ASPNETCORE_ENVIRONMENT='live'
$p = (Start-Process ".\Southwind.Terminal\bin\Debug\net8.0\Southwind.Terminal.exe" -ArgumentList "sql" -WorkingDirectory ".\Southwind.Terminal\bin\Debug\net8.0\" -NoNewWindow -Wait -PassThru)
if($p.ExitCode -eq -1){ Write-Host '"SQL Migrations" failed' -ForegroundColor DarkRed; exit; }
Write-Host
Write-Host '# START slot' $slotName -ForegroundColor DarkGreen
az webapp start --resource-group $resourceGroup --name $appName --slot $slotName
.\Framework\Utils\CheckUrl.exe alive $urlSlot
Write-Host
Write-Host '# SWAP slots' $slotName '<-> production' -ForegroundColor Magenta
az webapp deployment slot swap --resource-group $resourceGroup --name $appName --slot $slotName
.\Framework\Utils\CheckUrl.exe alive $url
Write-Host
Write-Host '# STOP slot' $slotName -ForegroundColor DarkRed
az webapp stop --resource-group $resourceGroup --name $appName --slot $slotName
.\Framework\Utils\CheckUrl.exe dead $urlSlot
Write-Host
Write-Host '# START slot' $slotName -ForegroundColor DarkGreen
az webapp start --resource-group $resourceGroup --name $appName --slot $slotName
.\Framework\Utils\CheckUrl.exe alive $urlSlot
Write-Host