1
votes

I have an Azure Release Pipeline with an Azure Powershell Task inline script that fails. I am running a self hosted build agent. The Powershell command works fine when I execute it locally from Windows Powershell. The task is attempting to start a DataFactory SSIS Integration Runtime:

Start-AzDataFactoryV2IntegrationRuntime -ResourceGroupName "MyResourceGroup"
                                             -DataFactoryName "my-data-factory"
                                             -Name "myIntegrationRuntime1"
                                             -Force

Firstly I get a warning:

WARNING: AzureRM.Profile already loaded. Az and AzureRM modules cannot be imported in the same session or used in the same script or runbook. If you are running PowerShell in an environment you control you can use the 'Uninstall-AzureRm' cmdlet to remove all AzureRm modules from your machine. If you are running in Azure Automation, take care that none of your runbooks import both Az and AzureRM modules. More information can be found here: https://aka.ms/azps-migration-guide.

And then the error:

The 'Start-AzDataFactoryV2IntegrationRuntime' command was found in the module 'Az.DataFactory', but the module could not be loaded. For more information, run 'Import-Module Az.DataFactory'.

When I look at the installed modules, I see both AzureRM and Az are installed, and although I run the command Import-Module Az.DataFactory I do not see it in the list of installed modules.

1

1 Answers

3
votes

WARNING: AzureRM.Profile already loaded. Az and AzureRM modules cannot be imported in the same session or used in the same script or runbook.

From last year, Az published as a new cross-platform PowerShell module that is completely independent of AzureRM. Since Az and AzureRM use the same dependencies with different versions, it's impossible to run Az and AzureRM side by side in the same PowerShell session. That's why you receive the first error message.

The first solution is remove all AzureRM modules if you don't have script that use AzureRM.

But, if you continue want to use AzureRM for part of scripts while also writing another scripts with Az. You can execute with Azure Powershell task V4.0.