Azure/login

Cannot bind argument to parameter 'Name' because it is null

Closed this issue · 3 comments

I'm getting "Error: Login failed with Error: Azure PowerShell login failed with error: Cannot bind argument to parameter 'Name' because it is null." using the following YAML on a self-hosted runner.

  - name: Log in with Azure
    uses: azure/login@v2
    with:
      creds: '${{ secrets.AZURE_CREDENTIALS }}'
      enable-AzPSSession: true

Here is the full debug:

##[debug]Reading creds in JSON...
::add-mask::***
::add-mask::***
Running Azure CLI Login.
##[debug]Azure CLI path: /usr/bin/az
##[debug]Azure CLI version used:
##[debug]azure-cli 2.61.0
##[debug]
##[debug]core 2.61.0
##[debug]telemetry 1.1.0
##[debug]
##[debug]Dependencies:
##[debug]msal 1.28.0
##[debug]azure-mgmt-resource 23.1.1
##[debug]
##[debug]Python location '/opt/az/bin/python3'
##[debug]Extensions directory '/home/runner/.azure/cliextensions'
##[debug]
##[debug]Python (Linux) 3.11.8 (main, May 16 2024, 03:47:28) [GCC 11.4.0]
##[debug]
##[debug]Legal docs and information: aka.ms/AzureCliLegal
##[debug]
##[debug]
##[debug]Your CLI is up-to-date.
##[debug]
/usr/bin/az cloud set -n azurecloud
Done setting cloud: "azurecloud"
Note: Azure/login action also supports OIDC login mechanism. Refer https://github.com/azure/login#configure-a-service-principal-with-a-federated-credential-to-use-oidc-based-authentication for more details.
Attempting Azure CLI login by using service principal with secret...
Subscription is set successfully.
Azure CLI login succeeds by using service principal with secret.
Running Azure PowerShell Login.
##[debug]Set PSModulePath as /usr/share:undefined
##[debug]The script to import the latest Az.Accounts: try ***
##[debug] $ErrorActionPreference = "Stop"
##[debug] $WarningPreference = "SilentlyContinue"
##[debug] $output = @***
##[debug] $latestModulePath = (Get-Module -Name 'Az.Accounts' -ListAvailable | Sort-Object Version -Descending | Select-Object -First 1).Path
##[debug] Import-Module -Name $latestModulePath
##[debug] $output['Success'] = $true
##[debug] $output['Result'] = $latestModulePath
##[debug] ***
##[debug] catch ***
##[debug] $output['Success'] = $false
##[debug] $output['Error'] = $_.exception.Message
##[debug] ***
##[debug] return ConvertTo-Json $output


Error: "Cannot bind argument to parameter 'Name' because it is null.",
Success: false


Error: Login failed with Error: Azure PowerShell login failed with error: Cannot bind argument to parameter 'Name' because it is null.. Double check if the 'auth-type' is correct. Refer to https://github.com/Azure/login#readme for more information.
##[debug]Error: Azure PowerShell login failed with error: Cannot bind argument to parameter 'Name' because it is null.
##[debug] at AzPSUtils. (/home/runner/_work/_actions/azure/login/v2/lib/main/index.js:4451:23)
##[debug] at Generator.next ()
##[debug] at fulfilled (/home/runner/_work/_actions/azure/login/v2/lib/main/index.js:4366:58)
##[debug] at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
##[debug]Node Action run completed with exit code 1
##[debug]Finishing: Log in with Azure

Hi @MezTemplar, do you use a self-hosted runner without Azure PowerShell installed? If yes, could you install Azure PowerShell module before using Azure Login Action?

Hi @MezTemplar, do you use a self-hosted runner without Azure PowerShell installed? If yes, could you install Azure PowerShell module before using Azure Login Action?

I added the Az module to pwsh in a step before the login and it worked so I guess that was the problem. Maybe a clearer message would be helpful?

Thanks @MezTemplar. Yes, you're right and it's tracked in #463 . I'll close this issue and let's track the error message improvement in #463.