FilterCair_Stack/FilterCair.Server/Deploy.ps1
2025-11-04 19:47:29 +01:00

48 lines
1.6 KiB
PowerShell
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# ============================================================
# 🌀 FilterCair Server Deploy Script
# ------------------------------------------------------------
# Builds the project for Linux, zips it, and deploys to Azure
# ------------------------------------------------------------
# Marc Wieland - 2025-11-04
# ============================================================
# Stop on first error
$ErrorActionPreference = "Stop"
# Variables
$projectPath = "C:\DEVQPDC\Masterarbeit\filtercair_dev\Masterarbeit_New\FilterCair.Server"
$publishFolder = "$projectPath\bin\Release\net9.0\linux-x64\publish"
$zipFile = "$projectPath\publish.zip"
$resourceGroup = "FilterCair-RG"
$appName = "filtercair-api"
Write-Host "Starting deploy for $appName..." -ForegroundColor Cyan
# 1⃣ Build the project
Write-Host "Publishing project for Linux (Release mode)..."
dotnet publish $projectPath -c Release -r linux-x64 --self-contained false
# 2⃣ Create ZIP
if (Test-Path $zipFile) {
Remove-Item $zipFile -Force
}
Write-Host "Compressing published output..."
Compress-Archive -Path "$publishFolder\*" -DestinationPath $zipFile -Force
# 3⃣ Deploy to Azure
Write-Host "Deploying to Azure WebApp ($appName)..."
az webapp deploy `
--resource-group $resourceGroup `
--name $appName `
--src-path $zipFile `
--type zip
if ($LASTEXITCODE -eq 0) {
Write-Host "Deployment successful! Opening site..." -ForegroundColor Green
Start-Process "https://$appName.azurewebsites.net/swagger"
} else {
Write-Host "Deployment failed. Check Azure Portal logs for details." -ForegroundColor Red
}
Write-Host "Done!"