0
votes

I'm having an issue with the Powershell task of Azure Devops.

If I run this from the a command window in my build server; it will work sqlcmd -S tcp:$(servername).database.windows.net -U $(login) -P $(password) -d $(dbname) -i $(sqlfile) -o $(outputfile)

but if I call that from an azure powershell task using Invoke-SqlCmd it fails with this error: "The term 'Disable-AzContextAutosave' is not recognized as the name of a cmdlet, function, ..."

1
What else is in your workflow before the Invoke-SqlCmd? That is a PowerShell cmdlet that is providing the error - not a T-SQL command. This must be coming from a different part of your Devops pipeline.Martin Cairney
I am fairly sure it is coming from there based on the logs. Right now testing if I have found the answer from docs.microsoft.com/en-us/powershell/module/sqlserver/… I appears that the -o in sqlcmd is outputfile when on command line but Out-File -FilePath when called from powershell. *fingerscrossedEdu Lorenzo

1 Answers

0
votes

You may try to Update Azure PowerShell modules to see whether it helps you. In addition, you can use Azure SQL Database Deployment task in Azure Pipeline, there are SQL Script File and Inline SQL Script types.

enter image description here