question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inline SQL Script doesn't work on 2017 Hosted Agent

See original GitHub issue

We’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:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:19 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
rajatagrawal-devcommented, Dec 11, 2017

The required SQL powershell modules have been installed in Hosted VS2017 agents.

0reactions
KrishnaAdityaBcommented, Apr 23, 2018

@Izzmo You seems to use private agent. On private agents, you need not run this each time.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found