【问题标题】:How to run azure cli commands in azure devops pipeline?如何在 azure devops 管道中运行 azure cli 命令?
【发布时间】:2019-06-12 20:12:46
【问题描述】:

尝试在 azure devops 管道中运行我们的 terraform 脚本。它调用一个 powershell 脚本,该脚本使用 azure cli 创建一个在 terraform 中本机不可用的资源。但是,我们遇到了不能同时安装 Az 和 AzureRm 模块的错误。


2019-06-07T15:45:48.1553235Z same session or used in the same script or runbook. If you are running PowerShell in an environment you control you can

2019-06-07T15:45:48.1554405Z use the 'Uninstall-AzureRm' cmdlet to remove all AzureRm modules from your machine. If you are running in Azure 

2019-06-07T15:45:48.1555064Z Automation, take care that none of your runbooks import both Az and AzureRM modules. More information can be found 

2019-06-07T15:45:48.1555474Z here: https://aka.ms/azps-migration-guide

尝试运行 Uninstall-AzureRm 但找不到该命令。

如何从 VS 2017 托管代理实例中删除 azurerm?

【问题讨论】:

标签: azure-devops terraform-provider-azure


【解决方案1】:

您似乎使用的是 PowerShell 命令行开关,而不是 Azure CLI。我建议您切换回在 PowerShell 命令中使用 AzureRm 而不是 Az。然后,如果您在本地使用新的 Az 模块,请确保设置了“Enable-AzureRmAlias”。这将确保您可以在两个位置运行相同的脚本。它并不完美,但应该能让你克服困难。

如果您不介意使用预览版,如果您将所有 PowerShell 任务切换为使用版本 4,那么您应该可以直接使用 Az 版本。

希望这会有所帮助。

【讨论】:

    猜你喜欢
    • 2020-04-02
    • 2020-01-11
    • 1970-01-01
    • 2021-09-10
    • 2021-09-27
    • 2020-03-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多