SQL DB CI/CD

CI














IF EXIST "..\bk" (
ECHO "Directory exists. Removing ..."
RMDIR /S /Q "..\bk"
)
git clone -b dev https://pm.aspireclan.com/FinPlan-Org/Baaki-2024/_git/BK ..\bk





CD


$ErrorActionPreference="Stop";If(-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent() ).IsInRole( [Security.Principal.WindowsBuiltInRole] "Administrator")){ throw "Run command in an administrator PowerShell prompt"};If($PSVersionTable.PSVersion -lt (New-Object System.Version("3.0"))){ throw "The minimum version of Windows PowerShell that is required by the script (3.0) does not match the currently running version of Windows PowerShell." };If(-NOT (Test-Path $env:SystemDrive\'ac_deploymentgroups'\'azagent01')){mkdir $env:SystemDrive\'ac_deploymentgroups'\'azagent01'}; cd $env:SystemDrive\'ac_deploymentgroups'\'azagent01'; for($i=1; $i -lt 100; $i++){$destFolder="A"+$i.ToString();if(-NOT (Test-Path ($destFolder))){mkdir $destFolder;cd $destFolder;break;}}; $agentZip="$PWD\agent.zip";$DefaultProxy=[System.Net.WebRequest]::DefaultWebProxy;$securityProtocol=@();$securityProtocol+=[Net.ServicePointManager]::SecurityProtocol;$securityProtocol+=[Net.SecurityProtocolType]::Tls12;[Net.ServicePointManager]::SecurityProtocol=$securityProtocol;$WebClient=New-Object Net.WebClient; $Uri='https://vstsagentpackage.azureedge.net/agent/3.225.2/vsts-agent-win-x64-3.225.2.zip';if($DefaultProxy -and (-not $DefaultProxy.IsBypassed($Uri))){$WebClient.Proxy= New-Object Net.WebProxy($DefaultProxy.GetProxy($Uri).OriginalString, $True);}; $WebClient.DownloadFile($Uri, $agentZip);Add-Type -AssemblyName System.IO.Compression.FileSystem;[System.IO.Compression.ZipFile]::ExtractToDirectory( $agentZip, "$PWD");.\config.cmd --deploymentgroup --deploymentgroupname "prod-ex-prxy-01 deployment group" --agent "prod-ex-prxy-01_azagent01" --runasservice --work '_work' --url 'https://pm.aspireclan.com/' --collectionname 'FinPlan-Org' --projectname 'Baaki-2024'; Remove-Item $agentZip;| Deployment Groups | ||||
|---|---|---|---|---|
| Category | Development | QA | Production | Comments |
| App | One agent each for all services (gw, auth, data, file, script, scheduler [windows service], etc.) per server | |||
| Web | Only one agent for web application per server | |||
| Load Balancer (LB) | One agent for the API gateway and another one for the Web Application per server | |||
| Proxy | One agent for the API gateway and another one for the Web Application per server | |||
| File | Only one agent for the file service per server | |||
| Swagger | NA | NA | One agent each for all services (gw, auth, data, file, script, etc.) per server. Currently only PROD server is being used | |






# Define the path to the before-deployment web.config
$beforeDeployConfigPath = "C:\inetpub\wwwroot\maintenance\beforedeploy\web.config"
# Define the path to your application's root directory
$siteRootPath = "C:\inetpub\wwwroot"
# Copy the before-deployment web.config to the root directory
Copy-Item -Path $beforeDeployConfigPath -Destination "$siteRootPath\web.config" -Force
Write-Host "Pre-deployment configuration applied."<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Rewrite to maintenance page" stopProcessing="true">
<match url=".*" />
<!-- Rewrite URL to maintenance page -->
<action type="Rewrite" url="/maintenance/maintenance.html" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
<!--ProjectGuid: A171D597-7DBB-45FA-BEE4-B88E8E2D33EB-->
# Define the path to the after-deployment web.config
$afterDeployConfigPath = "C:\inetpub\wwwroot\maintenance\afterdeploy\web.config"
# Define the path to your application's root directory
$siteRootPath = "C:\inetpub\wwwroot"
# Copy the after-deployment web.config to the root directory
Copy-Item -Path $afterDeployConfigPath -Destination "$siteRootPath\web.config" -Force
Write-Host "Post-deployment configuration applied."<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".Auth.Srvc.dll" stdoutLogEnabled="false" stdoutLogFile=".logsstdout" hostingModel="inprocess" />
</system.webServer>
</location>
</configuration>
<!--ProjectGuid: A171D597-7DBB-45FA-BEE4-B88E8E2D33EB-->

<!DOCTYPE html>
<html>
<head>
<title>Maintenance in Progress</title>
<style>
body, html {
margin: 0;
padding: 0;
height: 100%;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
overflow: hidden;
}
.background-image {
position: relative;
height: 100%;
//background-image: url('./Image-Maintenance.jpg');
background-size: cover;
background-position: center;
}
.background-image::after {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(255, 255, 255, 0.8);
}
.content {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
z-index: 1;
}
.maintenance-image {
max-width: 300px;
margin-bottom: 20px;
}
h1 {
margin-bottom: 10px;
color: #000000; /* Black color for h1 */
}
p {
font-size: 20px;
color: #000000; /* Black color for paragraph */
}
/* Responsive design adjustments */
@media (max-width: 600px) {
.content {
width: 90%;
}
p {
font-size: 18px;
}
}
</style>
</head>
<body>
<div class="background-image">
<div class="content">
<!-- <img src="./MAINLOGO.png" alt="Maintenance Image" class="maintenance-image"> -->
<h1>ASPIRE CLAN Site Maintenance in Progress</h1>
<p>We are currently performing scheduled maintenance. We should be back shortly. Thank you for your patience.</p>
</div>
</div>
</body>
</html>SQL CI


C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\












Display name:
Copy Files to: drop folderSource Folder:
$(Build.SourcesDirectory)\bin\ReleaseContents:
*.dacpacTarget Folder:
$(Build.ArtifactStagingDirectory) 




SQL CD









Display name:
Deploy DatabaseScript:
& SqlPackage.exe `
/Action:Publish `
/SourceFile:"$(System.DefaultWorkingDirectory)\_dev-bk-db-ci\drop\BK-DB.dacpac" `
/TargetConnectionString:"Server=63.98.29.63;Database=BK-DB-DEV;Integrated Security=True;Encrypt=True;TrustServerCertificate=True" `
/p:BlockOnPossibleDataLoss=false `
/p:CreateNewDatabase=true