4

We use Azure DevOps with a hosted VS2017 build agent. We would like to use the the new Az PowerShell module. However, the VS2017 hosted build agent has AzureRM installed on it. The documentation states You should not install Az side-by-side with AzureRM. Remove all AzureRM modules before installing Az. and this indeed is necessary because the two conflict. There is also no Az PowerShell build task.

So the question is, how do I use the Azure Az PowerShell module from an Azure DevOps hosted VS2017 build agent?

Murray Foxcroft
  • 12,785
  • 7
  • 58
  • 86

2 Answers2

1

I suppose the answer is - you dont (for the time being). Because you wont have permissions to remove the azure powershell module. Ok, apparently you can do that.

Another way to make it work, use a docker container as a build agent (inside hosted agent). That can have Az module, obviously.

4c74356b41
  • 69,186
  • 6
  • 100
  • 141
  • Docker is an interesting idea. You can remove AzureRM, you just uninstall it from the session and then install Az but I am hoping for a slicker solution so will hold out for more / better answers. See https://stackoverflow.com/questions/50375331/upgrade-azurerm-powershell-on-hosted-2017-agent-vsts-visual-studio-team-servi – Murray Foxcroft Feb 15 '19 at 10:01
  • you can always use your own agent. I'd personally not go the way of uninstalling azure.powershell from the agent. another thing you can do - use something like ACI or Azure Function and call those, they will have Az module and just execute your code – 4c74356b41 Feb 15 '19 at 10:10
  • I really don't want to secure, operate and manage my own agents. Uninstalling works better than you would expect. Functions is another good idea. – Murray Foxcroft Feb 15 '19 at 10:12
0

They cannot be installed side by side, however one can be installed in PowerShell (non core), and the other in PowerShell Core.

From the comments in the docs you specified:

Question: The document says not to install the modules side-by-side but is there any reason that we cannot run AzureRM in PowerShell 5.1 and AZ in PowerShell Core on the same machine?

Answer: No, no reason at all. In fact we are thinking of suggesting this as an advanced scenario for those with a substantial investment in AzureRM scripts

Community
  • 1
  • 1
Bernard Vander Beken
  • 4,848
  • 5
  • 54
  • 76