-
Notifications
You must be signed in to change notification settings - Fork 10
/
FabricDWProject-sqlpackage-install-first.yml
115 lines (97 loc) · 4.6 KB
/
FabricDWProject-sqlpackage-install-first.yml
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# This is a pipeline to creates a dacpac based on the contents of a Microsoft Fabric Data Warehouse Database Project
# From there it deploys the dacpac file to another Microsoft Fabric Data Warehouse
# Please note that you need the below variables created for this to work
# I recommend doing this by creating at least one variable group
# agentpool - The name of the agent pool you want to use (ideally a self-hosted one with latest sqlpackage installed)
# Otherwise you must put additional logic in this pipeline to deploy latest version of sqlpackage onto the agent
# BuildConfiguration - Configuration for build (Dev, Test, Release, etc)
# SQLPoolartifactname - A name for the created artifact
# AzureSubscription - A reference to an Azure subscription is required for the task to work, can be any one as will not be used
# aadSqlUsername - Azure AD/MS Entra account used
# aadSqlpw - Azure AD/MS Entra account used
# DestSQLConnString - The connection string for the Fabric Data Warehouse (found in settings)
# DestinationDW - The name of the Data Warehouse
# Targetfile - Name of the dacpac file created (default is dame name as .sqlproj file, in this case FabricDWproject.dacpac)
# This pipeline uses the variable group: SQLPackageTest
# Feel free to create youw own and use the below
variables:
- group: FabricDW
trigger:
- main
# In this pipeline I use a Microsoft-hosted agent
# To reference a self-hosted agent instead swap around the commented and uncommented references
pool:
vmImage: 'windows-latest'
# name: $(agentpool)
stages:
- stage: Pooldacpac
displayName: 'Build dacpac'
jobs:
- job: 'Builddacpac'
displayName: 'Build SQL Pool dacpac'
# pool:
# vmImage: 'windows-latest'
steps:
# First install latest version of SqlPackage
- task: PowerShell@2
inputs:
targetType: 'inline'
script: 'dotnet tool update -g microsoft.sqlpackage'
# Then build the project using a .NET task
- task: DotNetCoreCLI@2
displayName: 'Build the dacpac using dotnet'
inputs:
command: 'build'
projects: 'FabricDWProject.sqlproj'
arguments: '--configuration $(BuildConfiguration)'
#Then publish it as part of artifact
- task: PublishBuildArtifacts@1
displayName: 'Publishes dacpac as an artifact'
# Publishes the dacpac as part of an artifact within Azure DevOps
inputs:
PathtoPublish: 'bin/$(BuildConfiguration)'
ArtifactName: $(SQLPoolartifactname)
publishLocation: 'Container'
# Now lets deploy the dacpac to a Fabric Data Warehouse
# Note that doing this using a deployment job so can state environment
- stage: FabricDW
displayName: 'Deploy Data warehouse'
jobs:
- deployment: 'FabricDW'
displayName: 'Fabric Datawarehouse'
environment: Production
# Just to raise awareness that you can select pools at different stages
# pool:
# vmImage: 'windows-latest'
strategy:
runOnce:
deploy:
steps:
# First install latest version of SqlPackage through MSI to recognized by the deployment task properly
- task: PowerShell@2
displayName: 'upgrade sqlpackage'
inputs:
targetType: 'inline'
script: |
# use evergreen or specific dacfx msi link below
wget -O DacFramework.msi "https://aka.ms/dacfx-msi"
msiexec.exe /i "DacFramework.msi" /qn
- task: DownloadBuildArtifacts@0
displayName: 'Dowload Artifacts'
inputs:
buildType: 'current'
downloadType: 'specific'
artifactName: '$(SQLPoolartifactname)'
downloadPath: '$(System.ArtifactsDirectory)'
- task: SqlAzureDacpacDeployment@1
displayName: 'Install DACPAC on Fabric DataWarehouse'
inputs:
azureSubscription: $(AzureSubscription)
AuthenticationType: 'aadAuthenticationPassword'
aadSqlUsername: '$(aadSqlUsername)'
aadSqlPassword: '$(aadSqlpw)'
ServerName: $(DestSQLConnString)
DatabaseName: '$(DestinationDW)'
deployType: 'DacpacTask'
DeploymentAction: 'Publish'
DacpacFile: '$(System.ArtifactsDirectory)\$(SQLPoolartifactname)\$(Targetfile)'