Skip to content

Commit 00a7b5a

Browse files
committed
sql script
1 parent adbd33e commit 00a7b5a

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

docs/pipelines/targets/azure-sqldb.md

+9-2
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ if ((Get-AzureSqlDatabaseServerFirewallRule -ServerName $ServerName -RuleName $F
151151
```
152152

153153
#### [YAML](#tab/yaml/)
154+
154155
::: moniker range=">= azure-devops-2019"
155156

156157
Add the following to your azure-pipelines.yml file to run a SQL script.
@@ -168,9 +169,10 @@ variables:
168169

169170
steps:
170171
- task: AzurePowerShell@5
171-
displayName: Azure PowerShell script: FilePath
172+
displayName: 'Azure PowerShell script'
172173
inputs:
173174
azureSubscription: '$(AzureSubscription)'
175+
ScriptType: filePath
174176
ScriptPath: '$(Build.SourcesDirectory)\scripts\SetAzureFirewallRule.ps1'
175177
ScriptArguments: '-ServerName $(ServerName) -ResourceGroupName $(ResourceGroupName)'
176178
azurePowerShellVersion: LatestVersion
@@ -182,9 +184,10 @@ steps:
182184
arguments: '-S $(ServerFqdn) -U $(AdminUser) -P $(AdminPassword) -d $(DatabaseName) -i $(SQLFile)'
183185

184186
- task: AzurePowerShell@5
185-
displayName: Azure PowerShell script: FilePath
187+
displayName: 'Azure PowerShell script'
186188
inputs:
187189
azureSubscription: '$(AzureSubscription)'
190+
ScriptType: filePath
188191
ScriptPath: '$(Build.SourcesDirectory)\scripts\RemoveAzureFirewallRule.ps1'
189192
ScriptArguments: '-ServerName $(ServerName) -ResourceGroupName $(ResourceGroupName)'
190193
azurePowerShellVersion: LatestVersion
@@ -199,6 +202,7 @@ YAML is not supported in TFS.
199202
::: moniker-end
200203
201204
#### [Classic](#tab/classic/)
205+
202206
When you set up a build pipeline, make sure that the SQL script to deploy the database and the Azure PowerShell scripts to configure firewall rules are part of the build artifact.
203207
204208
When you set up a release pipeline, choose **Start with an Empty process**, link the artifacts from build, and then use the following tasks:
@@ -207,7 +211,10 @@ When you set up a release pipeline, choose **Start with an Empty process**, link
207211
- Second, use a [Command line](/azure/devops/pipelines/tasks/reference/cmd-line-v2) task to run the SQL script using the **SQLCMD** tool. The arguments to this tool are `-S {database-server-name}.database.windows.net -U {username}@{database-server-name} -P {password} -d {database-name} -i {SQL file}` For example, when the SQL script is coming from an artifact source, **{SQL file}** will be of the form: `$(System.DefaultWorkingDirectory)/contoso-repo/DatabaseExample.sql`.
208212
- Third, use another [Azure PowerShell](/azure/devops/pipelines/tasks/reference/azure-powershell-v5) task to remove the firewall rule in Azure.
209213

214+
:::image type="content" source="media/classic-sql.png" alt-text="A screenshot showing a classic pipeline to run SQL script.":::
215+
210216
* * *
217+
211218
## Azure service connection
212219

213220
The **Azure SQL Database Deployment** task is the primary mechanism to deploy a database to Azure. This task, as with other built-in Azure tasks, requires an Azure service connection as an input. The Azure service connection stores the credentials to connect from Azure Pipelines or TFS to Azure.
27 KB
Loading

0 commit comments

Comments
 (0)