简体   繁体   English

Azure 突触部署失败

[英]Azure synapse deployment failing

I am trying to deploy SQL files to an Azure Synapse Analytics dedicated SQL pools using PowerShell script in an Azure Devops pipeline.我正在尝试在 Azure Devops 管道中使用 PowerShell 脚本将 SQL 文件部署到 Azure Synapse Analytics 专用 SQL 池。

I have a folder with SQL files and after defining array of files I am trying to run foreach loop for array and trying to Invoke-Sqlcmd to deploy files but first SQL file get deployed (object is created) and then I get error:我有一个包含 SQL 个文件的文件夹,在定义文件数组后,我尝试为数组运行 foreach 循环并尝试Invoke-Sqlcmd -Sqlcmd 来部署文件,但首先部署了 SQL 个文件(创建了对象),然后出现错误:

Msg 104309, Level 16, State 1, Line 1 There are no batches in the input script. Msg 104309, Level 16, State 1, Line 1 输入脚本中没有批处理。

Below is my piece of code:下面是我的一段代码:

$files='$(Build.SourcesDirectory)\folder1\'

foreach ($s in $files)
{
Invoke-sqlcmd -ServerInstance $(server) -Database $(db) -InputFile $s -Credential $(cred)}

Azure Synapse Analytics dedicated SQL pools scripts are sensitive to empty batches, eg this script would generate the same error: Azure Synapse Analytics 专用 SQL 池脚本对空批次敏感,例如此脚本会生成相同的错误:

Msg 104309, Level 16, State 1, Line 1 There are no batches in the input script. Msg 104309, Level 16, State 1, Line 1 输入脚本中没有批处理。

-- xx
GO

However the truth is you get the same error in Synapse Studio and SQL Server Management Studio (SSMS), so I suggest you run through your scripts and use the Parse button ( Ctrl + F5 ) in SSMS, which parses the script but does not execute it.然而,事实是你在 Synapse Studio 和 SQL Server Management Studio (SSMS) 中遇到了同样的错误,所以我建议你运行脚本并使用 SSMS 中的解析按钮 ( Ctrl + F5 ),它解析脚本但执行它。 This will help you track down your error:这将帮助您追踪错误:

安全管理系统

In summary don't have batches that don't do anything.总之,没有不做任何事情的批次。

I was able to get a simple local example added by including dir and using the FullName method to get the full path:我能够通过包含dir并使用FullName方法获取完整路径来添加一个简单的本地示例:

$files = dir "D:\temp\Powershell\*.sql"

foreach ($s in $files) {
    #$s.Name
    Invoke-Sqlcmd -ServerInstance '.\sql2019x' -Database 'tempdb' -InputFile $s.FullName
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM