如何在azure devops管道中运行azure cli命令?

时间:2019-06-07 16:09:07

标签: azure-devops terraform-provider-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?

1 个答案:

答案 0 :(得分:1)

似乎您正在使用PowerShell Commandlet而不是Azure CLI。我建议您切换回在PowerShell命令中使用AzureRm而不是Az。然后,如果您在本地使用新的Az模块,则只需确保设置“ Enable-AzureRmAlias”即可。这将确保您可以在两个位置运行相同的脚本。它不是完美的,但是应该让您摆脱困境。

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

希望这会有所帮助。