Jyotirmoy
Jyotirmoy

Reputation: 730

AzurePowerShell@4 - powershell commands fail to execute on azure pipeline

As a part of my yml pipeline definition, I have a AzurePowerShell@4 task, following is an extract from my pipeline definition

stages:
- stage: DeployDemoCluster
  jobs:
  - job: 'DeployAKSAndAll'
    pool:
      vmImage: 'windows-latest'
    steps: 
      - task: AzurePowerShell@4
        displayName: Store AI instrumentation key for Inbound Processor in central KeyVault
        inputs:
          azureSubscription: 'service-connection'
          azurePowerShellVersion: LatestVersion
          pwsh: true
          ScriptType: 'FilePath'
          ScriptPath: 'AKS/ps/update_kv_firewall.ps1'

The issue is, within my update_kv_firewall.ps1, all the powershell commands fail with the error, for example:

[error]Login-AzureRmAccount : The term 'Login-AzureRmAccount' is not recognized as the name of a cmdlet, function, script file, or operable program.

The script when executed individually / standalone, works perfectly fine.

what am I missing here?

Upvotes: 0

Views: 542

Answers (1)

Ivan Glasenberg
Ivan Glasenberg

Reputation: 30025

As per your comment: the command "Get-AzKeyVault" runs without any errors, while 'Get-AzureRmVirtualNetwork' leads to errors.

Then I'm sure that you're installing the new Az module of azure powershell. So the command like Get-AzKeyVault can work.

Since you're installing Az module, please use all the commands from Az module. Almost each azure Rm command has an equivalent azure Az command, you can find it from the Az command list.

Note: the command like Get-AzureRmVirtualNetwork / Login-AzureRmAccount is from azure RM module, which will be retired this year later.

Upvotes: 1

Related Questions