gpt4 book ai didi

azure - PowerShell 通过 Azure 管道打开所有网络

转载 作者:行者123 更新时间:2023-12-03 07:04:52 25 4
gpt4 key购买 nike

我编写了一个 power-shell,它在 Windows 机器上通过 PS 编辑器运行良好。在运行此命令之前,系统会提示我输入用户名进行身份验证。

$subscription = "dev"
Connect-AzAccount -Subscription $subscription
$keyvaultname = "kv-dev"
Update-AzKeyVaultNetworkRuleSet -DefaultAction Allow -VaultName $keyvaultname

当我在 Azure 管道中运行相同的脚本(使用 PowerShell 任务)时,它会引发以下错误。我删除了 Connect-AzAccount。

Update-AzKeyVaultNetworkRuleSet' is not recognized as the name of a cmdlet, function, 
script file, or operable program. Check the spelling of the name, or if a path was
included, verify that the path is correct and try again.

如何使用 Power Shell 任务从 azure 管道运行它。

最佳答案

要在管道作业中执行 Azure PowerShell 命令来管理 Azure 资源,您应该使用 Azure PowerShell task而不是PowerShell task .

您需要设置 Azure Resource Manager service connection (ARM 连接)用于 Azure PowerShell 任务。此 ARM 连接用作身份验证,您不应直接在 PowerShell 脚本中设置身份验证。

关于azure - PowerShell 通过 Azure 管道打开所有网络,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71596978/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com