Azure CLI 2.x is not installed on this machine
Asked Answered
A

2

4

I'm trying to upload blobs using "az storage blob upload-batch". I got below two exceptions.

  1. ##[error]Azure CLI 2.x is not installed on this machine.
  2. ##[error]Script failed with error: Error: Unable to locate executable file: 'pwsh'. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.
    task: AzureCLI@2
    displayName: 'Upload Files'
    inputs:
      azureSubscription: 'xxxxxxx'
      scriptType: 'pscore'
      scriptLocation: 'inlineScript'
      inlineScript: |
        $subscriptionName = $(az account show --query 'name' --output tsv) 
        az storage blob upload-batch `
          --subscription $subscriptionName `
          --account-name xxxxxxxxx `
          --source "C:\xxx\yyy" `
          --destination MyContainerName `
          --auth-mode login
Aruspex answered 23/12, 2021 at 10:54 Comment(1)
try to uninstall and install like here: adamtheautomator.com/install-azure-cliFloatplane
D
2

Thank you @N MZ , Posting your suggestion as an answer to help other community members.

##[error]Azure CLI 2.x is not installed on this machine.

##[error]Script failed with error: Error: Unable to locate executable file: 'pwsh'. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.

For this above errors we need to install Azure cli and check running cmd az version if its installed or not .

enter image description here

For More information please refer the below links:

Daemon answered 27/12, 2021 at 8:40 Comment(0)
C
2

Although not the best approach, for a quick test, you could install az cli while running the job steps:

jobs:
  - job: my_job
    steps:
    - script: curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
      displayName: 'install az cli'
Cassaundra answered 16/12, 2022 at 20:35 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.