首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Azure Webjob错误调用-Sqlcmd:术语“Invoke-Sqlcmd”未被识别

Azure Webjob错误调用-Sqlcmd:术语“Invoke-Sqlcmd”未被识别
EN

Stack Overflow用户
提问于 2016-09-02 16:48:13
回答 1查看 731关注 0票数 0

Azure WebJobs运行Powershell脚本,但调用-Sqlcmd在WebJob中失败。怎么修?脚本在本地PowerShell ISE中工作,但在Azure but作业中失败:

代码语言:javascript
复制
    $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运行详细信息输出:

代码语言:javascript
复制
[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

找了又找,却被困住了,不知道下一步该做什么。提前感谢您的帮助!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-09-05 02:57:50

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39297299

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档