user2368632
user2368632

Reputation: 1073

How to run azure cli commands in azure devops pipeline?

Trying to run our terraform script in a azure devops pipeline. It invokes a powershell script that uses azure cli to create a resource that is not natively available in terraform. However, we run into error that Az and AzureRm modules cannot both be installed.


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

Tried running Uninstall-AzureRm but the command is not found.

How do you remove azurerm from VS 2017 Hosted agent instance?

Upvotes: 0

Views: 919

Answers (1)

Jamie
Jamie

Reputation: 3372

It appears that you are using the PowerShell commandlets instead of the Azure CLI. I would suggest you switch back to using AzureRm in your PowerShell commands instead of Az. Then just make sure that you set the "Enable-AzureRmAlias" if you are using the new Az module locally. This will ensure that you can run the same script in both locations. It isn't perfect, but should get you over the hump.

If you don't mind using preview stuff, if you switch all your PowerShell tasks to use version 4, then you should be able to use the Az versions straight up.

Hope this helps.

Upvotes: 1

Related Questions