Azure Webjob Powershell 错误调用-Sqlcmd:无法识别术语 'Invoke-Sqlcmd'

Azure Webjob Powershell Error Invoke-Sqlcmd : The term 'Invoke-Sqlcmd' is not recognized

A​​zure WebJobs 运行 Powershell 脚本,但 Invoke-Sqlcmd 在 WebJob 中失败。怎么修? 脚本在本地 PowerShell ISE 中有效,但在 Azure Webjob 中失败:

    $result = Invoke-Sqlcmd -Query 'SELECT AlertLine FROM HR.AlertRecordsOpenInline;' `
    -ServerInstance 'xxxxxxxx.database.windows.net' `
    -Username 'xxxxx@xxxxxx' -Password 'xxxxxx' -Database 'xxxxxx'
foreach($item in $result){
    [string]$Results += ($item.AlertLine)
    }
$Results

WebJob 运行 详细信息输出:

[09/02/2016 16:09:00 > da15b0: SYS INFO] Status changed to Initializing
[09/02/2016 16:09:00 > da15b0: SYS INFO] Run script 'Invoke-Sqlcmd.ps1' with script host - 'PowerShellScriptHost'
[09/02/2016 16:09:00 > da15b0: SYS INFO] Status changed to Running
[09/02/2016 16:09:01 > da15b0: ERR ] Invoke-Sqlcmd : The term 'Invoke-Sqlcmd' is not recognized as the name of a 
[09/02/2016 16:09:01 > da15b0: ERR ] cmdlet, function, script file, or operable program. Check the spelling of the 
[09/02/2016 16:09:01 > da15b0: ERR ] name, or if a path was included, verify that the path is correct and try again.
[09/02/2016 16:09:01 > da15b0: ERR ] At D:\local\Temp\jobs\triggered\Invoke-Sqlcmd\ni4ywn1l.sgn\Invoke-Sqlcmd.ps1:1 
[09/02/2016 16:09:01 > da15b0: ERR ] char:11
[09/02/2016 16:09:01 > da15b0: ERR ] + $result = Invoke-Sqlcmd -Query 'SELECT AlertLine FROM 
[09/02/2016 16:09:01 > da15b0: ERR ] HR.AlertRecordsOpenInline; ...
[09/02/2016 16:09:01 > da15b0: ERR ] +           ~~~~~~~~~~~~~
[09/02/2016 16:09:01 > da15b0: ERR ]     + CategoryInfo          : ObjectNotFound: (Invoke-Sqlcmd:String) [], Comma 
[09/02/2016 16:09:01 > da15b0: ERR ]    ndNotFoundException
[09/02/2016 16:09:01 > da15b0: ERR ]     + FullyQualifiedErrorId : CommandNotFoundException
[09/02/2016 16:09:01 > da15b0: ERR ]  
[09/02/2016 16:09:01 > da15b0: SYS INFO] Status changed to Success

搜索了又搜索,但卡住了,不知道下一步该尝试什么。预先感谢您的帮助!

SQLPS 模块未安装在 Azure WebJobs 环境中,我不知道安装其他模块的方法。您是否尝试过 Azure Automation,如果它没有您需要的模块,您可以添加自己的模块或从库中安装模块。