0

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?

2
  • I managed to bypass the login issue, but it fails on the next command anyway, error being : "##[error]The term 'Get-AzureRmVirtualNetwork' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again." Commented Jan 8, 2020 at 21:24
  • It seems like some commands run without an issue. For example, the command "Get-AzKeyVault" runs without any errors, while 'Get-AzureRmVirtualNetwork' leads to errors. Any links to indicate what are the limitations here? Commented Jan 8, 2020 at 21:38

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.