1
votes

I run the following in PowerShell ISE Connect-AzAccount and it works fine , but within Jenkins when run as a Powershell command I get the following error:

The term 'Connect-AzAccount' 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.

Why would this happen ?

1

1 Answers

0
votes

Couple of things to try out:

  • You do not install AZ and Azure RM side by side , if you have it in the machine , please uninstall the Azure RM

  • Please try running the following command in order:

    Install-Module Az Import-Module Az Connect-AzAccount

Additional reference:

https://docs.microsoft.com/en-us/azure/jenkins/execute-cli-jenkins-pipeline

Using Azure CLI in Jenkins pipeline

https://wiki.jenkins.io/display/JENKINS/Azure+CLI+Plugin

Hope it helps.