Skip to content

Commit e211be2

Browse files
authored
Merge pull request #20021 from MicrosoftDocs/master
8/19 AM Publish
2 parents c1e090c + 69f7ea7 commit e211be2

1 file changed

Lines changed: 55 additions & 1 deletion

File tree

docs/tools/sqlpackage/sqlpackage-pipelines.md

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ms.assetid: 198198e2-7cf4-4a21-bda4-51b36cb4284b
99
author: "dzsquared"
1010
ms.author: "drskwier"
1111
ms.reviewer: "maghan"
12-
ms.date: 06/25/2021
12+
ms.date: 08/18/2021
1313
---
1414

1515
# SqlPackage in development pipelines
@@ -46,6 +46,60 @@ By using the [run](https://docs.github.com/en/free-pro-team@latest/actions/refer
4646
4747
:::image type="content" source="media/sqlpackage-pipelines-github-action.png" alt-text="GitHub action output displaying build number 15.0.4897.1":::
4848
49+
50+
## Obtaining SqlPackage diagnostics in a pipeline agent
51+
52+
Diagnostic information from SqlPackage is available in the command line through the parameter `/DiagnosticsFile`, which can be used in virtual environments such as Azure Pipelines and GitHub Actions. The diagnostic information is written to a file in the working directory. The file name is dictated by the `/DiagnosticsFile` parameter.
53+
54+
### Azure Pipelines
55+
Adding the `/DiagnosticsFile` parameter to the "Additional SqlPackage.exe Arguments" field in the Azure Pipeline SqlAzureDacpacDeployment configuration will cause the SqlPackage diagnostic information to be written to the file specified. Following the SqlAzureDacpacDeployment task, the diagnostic file can be made available outside of the virtual environment by publishing a pipeline artifact as seen in the example below.
56+
57+
```yaml
58+
- task: SqlAzureDacpacDeployment@1
59+
inputs:
60+
azureSubscription: '$(azuresubscription)'
61+
AuthenticationType: 'server'
62+
ServerName: '$(servername)'
63+
DatabaseName: '$(databasename)'
64+
SqlUsername: '$(sqlusername)'
65+
SqlPassword: '$(sqladminpassword)'
66+
deployType: 'DacpacTask'
67+
DeploymentAction: 'Publish'
68+
DacpacFile: '$(Build.Repository.LocalPath)\$(dacpacname).dacpac'
69+
AdditionalArguments: '/DiagnosticsFile:$(System.DefaultWorkingDirectory)/output.log'
70+
IpDetectionMethod: 'AutoDetect'
71+
72+
- task: PublishPipelineArtifact@1
73+
inputs:
74+
targetPath: '$(System.DefaultWorkingDirectory)/output.log'
75+
artifact: 'Diagnostic File'
76+
publishLocation: 'pipeline'
77+
```
78+
79+
After the pipeline run, the diagnostic file can be downloaded from the run summary page under "Published Artifacts".
80+
81+
### GitHub Actions
82+
Adding the `/DiagnosticsFile` parameter to the "arguments" field in the GitHub Action sql-action configuration will cause the SqlPackage diagnostic information to be written to the file specified. Following the sql-action task, the diagnostic file can be made available outside of the virtual environment by publishing an artifact as seen in the example below.
83+
84+
```yaml
85+
- name: Azure SQL Deploy
86+
uses: Azure/sql-action@v1
87+
with:
88+
# Name of the Azure SQL Server name, like Fabrikam.database.windows.net.
89+
server-name: ${{ secrets.AZURE_SQL_SERVER }}
90+
# The connection string, including authentication information, for the Azure SQL Server database.
91+
connection-string: ${{ secrets.AZURE_SQL_CONNECTION_STRING }}
92+
# Path to DACPAC file to deploy
93+
dacpac-package: .\DatabaseProjectAdventureWorksLT\bin\Release\DatabaseProjectAdventureWorksLT.dacpac
94+
# additional SqlPackage.exe arguments
95+
arguments: /DiagnosticsFile:DatabaseProjectAdventureWorksLT/DiagnosticLog.log
96+
97+
- uses: actions/upload-artifact@v2
98+
with:
99+
name: 'DiagnosticLog.txt'
100+
path: 'DatabaseProjectAdventureWorksLT/DiagnosticLog.log'
101+
```
102+
49103
## Update SqlPackage on the pipeline agent
50104

51105
In some scenarios, the current version of SqlPackage installed in the pipeline environment may be insufficient. An additional step can be used to install a newer version of SqlPackage. It is important to run the install step before running any DacPac or BacPac operations in the pipeline. This task can be combined with a step to [check the version](#checking-the-sqlpackage-version) to ensure that the upgrade completed as expected.

0 commit comments

Comments
 (0)