How to execute SQL against an Azure SQL database as part of a PowerShell script in a VSTS build task in a hosted agent?
There are many tasks available for build definitions: we can execute a PowerShell script
or deploy SQL using DACPAC or SQLCMD
or even execute PowerShell on remote machines
but how to simply execute SQL as part of a PowerShell script? Invoke-Sqlcmd isn't available as part of the 'Azure PowerShell' task.
I guess it would be possible to remote desktop to an app service, install the SQL Server related bits there and use 'PowerShell on Target Machines' but I feel there has to be a simpler way - perhaps I'm just missing something obvious
You can use Azure SQL Database Deployment task, there are SQL Script File and Inline SQL Script types.
Note: You can use Hosted agent, but not Hosted VS 2017 agent.