Inline SQL Script doesn't work on 2017 Hosted Agent
See original GitHub issueWe’re using the Azure SQL Database Deployment task’s “Inline SQL Script” in a few build definitions.
https://github.com/Microsoft/vsts-tasks/blob/master/Tasks/SqlAzureDacpacDeployment/README.md
This worked on the “Hosted” queue, but fails on the “Hosted 2017” queue:
==============================================================================
Task : Azure SQL Database Deployment
Description : Deploy Azure SQL DB using DACPAC or run scripts using SQLCMD
Version : 1.1.23
Author : Microsoft Corporation
Help : [More Information](https://aka.ms/sqlazuredeployreadme)
==============================================================================
tempFile= d:\a\_temp\tmp6EE1.tmp
Invoke-Sqlcmd -ServerInstance (snip) -Inputfile "d:\a\_temp\tmp6EE1.tmp" -QueryTimeout 600 -ConnectionTimeout 120
SQL Powershell Module is not installed on your agent machine. Please follow steps given below to execute this task
1. Install PowershellTools & SharedManagementObjects(dependency), from https://www.microsoft.com/en-us/download/details.aspx?id=52676 (2016)
2. Restart agent machine after installing tools to register Module path updates
3. Run Import-Module SQLPS on your agent Powershell prompt. (This step is not required on Powershell 3.0 enabled machines)
The term 'Invoke-Sqlcmd' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
******************************************************************************
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:19 (8 by maintainers)
Top Results From Across the Web
Inline SQL Script doesn't work on 2017 Hosted Agent #5817
We're using the Azure SQL Database Deployment task's "Inline SQL Script" in a few build definitions.
Read more >Azure devops- Pipeline Task running sql script against loaddb ...
I am migrating an azure devops CI pipeline from vmImage: 'VS2017-Win2016' to 'windows-2022/2019'. The script first installs LocalDb on the ...
Read more >Deploy to Azure SQL Database - Microsoft Learn
To run SQL scripts as part of a pipeline, you'll need Azure PowerShell scripts to create and remove firewall rules in Azure.
Read more >Error in Azure DevOps SQL Server database deploy task not ...
I'm using Azure DevOps SQL Server database deploy task to run a SQL Server Agent Job using its inline SQL feature which works....
Read more >Check if File Exists Before Deploying SQL Script to Azure SQL ...
First, you need to run the job on a self-hosted agent that is located on a virtual machine that has access to the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The required SQL powershell modules have been installed in Hosted VS2017 agents.
@Izzmo You seems to use private agent. On private agents, you need not run this each time.