Azure / powershell

GH Action to run Az PowerShell scripts for developers and administrators to develop, deploy, and manage Microsoft Azure applications.
MIT License
56 stars 35 forks source link

Initializing Az Module - Error #88

Closed extravio closed 8 months ago

extravio commented 8 months ago

Hi,

I have a self-hosted runner on RHEL 9 with:

and I get the following error when executing the azure/powershell action: Error: You cannot call a method on a null-valued expression.

Run azure/powershell@v1
[...]
Validating inputs
Module Az latest installed from hostedAgentFolder
Initializing Az Module
/usr/bin/pwsh -NoLogo -NoProfile -NonInteractive -Command Test-Path (Join-Path /usr/share az_*)
/usr/bin/pwsh -NoLogo -NoProfile -NonInteractive -Command try ***
            $ErrorActionPreference = "Stop"
            $WarningPreference = "SilentlyContinue"
            $output = @***
            $data = Get-Module -Name Az -ListAvailable | Sort-Object Version -Descending | Select-Object -First 1
            $output['AzVersion'] = $data.Version.ToString()
            $output['Success'] = "true"
        ***
        catch ***
            $output['Error'] = $_.exception.Message
        ***
        return ConvertTo-Json $output
False
***
  "Error": "You cannot call a method on a null-valued expression."
***
Error: Error: You cannot call a method on a null-valued expression.

I previously had the same configuration on Ubuntu and it was working fine.

Any ideas?

YanaXu commented 8 months ago

Hi @extravio, could you login to your self-hosted runner machine, open powershell, and run the following cmdlets?

$data = Get-Module -Name Az -ListAvailable | Sort-Object Version -Descending | Select-Object -First 1
Write-Host $data.Version.ToString()
extravio commented 8 months ago

Hi @YanaXu , Thanks for the quick reply. I made me realize that it was a problem with permissions. The user on my runner did not have access to the folder where the modules were installed. chmod -R 755 /usr/local/share/powershell/ fixed my issue