Skip to content

Commit 549227a

Browse files
committed
[ci-skip] add azure-pipelines.yml
1 parent cff848d commit 549227a

File tree

1 file changed

+103
-0
lines changed

1 file changed

+103
-0
lines changed

azure-pipelines.yml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# This is a pipeline to creates a dacpac
2+
# From there it deploys the dacpac file to SQL Server
3+
4+
trigger:
5+
- '*'
6+
pr:
7+
- main
8+
- master
9+
resources:
10+
- repo: self
11+
12+
13+
## Configure variables bellow
14+
# agentpool - The name of the agent pool you want to use (ideally a self-hosted one with latest sqlpackage installed)
15+
# Otherwise you must put additional logic in this pipeline to deploy latest version of sqlpackage onto the agent
16+
# BuildConfiguration - Configuration for build (Dev, Test, Release, etc)
17+
# SQLPoolartifactname - A name for the created artifact
18+
# AzureSubscription - A reference to an Azure subscription is required for the task to work, can be any one as will not be used
19+
# aadSqlUsername - Azure AD/MS Entra account used
20+
# aadSqlpw - Azure AD/MS Entra account used
21+
# DestSQLConnString - The connection string for the Fabric Data Warehouse (found in settings)
22+
# DestinationDW - The name of the Data Warehouse
23+
# Targetfile - Name of the dacpac file created (default is dame name as .sqlproj file, in this case FabricDWproject.dacpac)
24+
25+
variables:
26+
- group: DbProject
27+
28+
# To reference a self-hosted agent instead swap around the commented and uncommented references
29+
pool:
30+
vmImage: 'windows-latest'
31+
# name: $(agentpool)
32+
33+
stages:
34+
- stage: BuildDacpac
35+
displayName: 'Build dacpac'
36+
jobs:
37+
- job: 'BuildDacpac'
38+
displayName: 'Build SQL Pool dacpac'
39+
# pool:
40+
# vmImage: 'windows-latest'
41+
steps:
42+
- task: PowerShell@2
43+
inputs:
44+
targetType: 'inline'
45+
script: 'dotnet tool update -g microsoft.sqlpackage'
46+
47+
- task: DotNetCoreCLI@2
48+
displayName: 'Build the dacpac using dotnet'
49+
inputs:
50+
command: 'build'
51+
projects: 'DbProject/DbProject.sqlproj'
52+
#arguments: '--configuration $(BuildConfiguration)'
53+
54+
- task: PublishBuildArtifacts@1
55+
displayName: 'Publishes dacpac as an artifact'
56+
# Publishes the dacpac as part of an artifact within Azure DevOps
57+
inputs:
58+
PathtoPublish: 'bin/$(BuildConfiguration)'
59+
ArtifactName: $(SQLPoolartifactname)
60+
publishLocation: 'Container'
61+
62+
# Note that doing this using a deployment job so can state environment
63+
- stage: Deploy
64+
displayName: 'Deploy Db'
65+
dependsOn: BuildDacpac
66+
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
67+
jobs:
68+
- deployment: 'DeployDb'
69+
displayName: 'Deploy db'
70+
environment: $(environment)
71+
# pool:
72+
# vmImage: 'windows-latest'
73+
strategy:
74+
runOnce:
75+
deploy:
76+
steps:
77+
- task: PowerShell@2
78+
displayName: 'upgrade sqlpackage'
79+
inputs:
80+
targetType: 'inline'
81+
script: |
82+
wget -O DacFramework.msi "https://aka.ms/dacfx-msi"
83+
msiexec.exe /i "DacFramework.msi" /qn
84+
- task: DownloadBuildArtifacts@0
85+
displayName: 'Dowload build Artifacts'
86+
inputs:
87+
buildType: 'current'
88+
downloadType: 'specific'
89+
artifactName: '$(SQLPoolartifactname)'
90+
downloadPath: '$(System.ArtifactsDirectory)'
91+
92+
- task: SqlAzureDacpacDeployment@1
93+
displayName: 'Deploy DACPAC'
94+
inputs:
95+
azureSubscription: $(AzureSubscription)
96+
AuthenticationType: 'aadAuthenticationPassword'
97+
aadSqlUsername: '$(aadSqlUsername)'
98+
aadSqlPassword: '$(aadSqlpw)'
99+
ServerName: $(DestSQLConnString)
100+
DatabaseName: '$(DestinationDW)'
101+
deployType: 'DacpacTask'
102+
DeploymentAction: 'Publish'
103+
DacpacFile: '$(System.ArtifactsDirectory)\$(SQLPoolartifactname)\$(Targetfile)'

0 commit comments

Comments
 (0)