如何在Azure中使用Jenkins中的Set-AzContext设置订阅?

lg40wkob  于 2022-11-02  发布在  Jenkins
关注(0)|答案(1)|浏览(148)

我在Jenkins中有一个自由式作业,其中包含powershell构建步骤,如下所示:

az account clear
$pwd1 = "testpwd"
$uname = "testuser"
az login -u "$uname" -p "$pwd1"
Set-AzContext -SubscriptionId <subscription-id>
...

但我得到的错误:

Set-AzContext : The term 'Set-AzContext' is not recognized as the name of a cmdlet, function, script file, or operable

你知道为什么会发生这种事吗?或者我该怎么解决?

rqqzpn5f

rqqzpn5f1#

Az模块似乎不可用。请运行以下命令:

Get-Module -Name Az -All

如果缺少Set-AzContext,或者根本没有列出任何内容,则需要安装Az模块。为此,请参阅official documentation

相关问题