microsoft / microsoft/powerbi-powershell

Azure Function App fails with ERROR: Cannot bind argument to parameter 'InputObject' because it is null.

Open
#252 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
413
Forks
134
Avg merge
33m
Merged PRs (30d)
1

Description

Alright, here is my code:

$AppId = $env:SPappId
$powerbiSP = $env:powerbiSP
$PWord = ConvertTo-SecureString -String $powerbiSP -AsPlainText -Force
$Credential = New-Object -TypeName "System.Management.Automation.PSCredential" -ArgumentList $AppId, $PWord
try { 
    Connect-PowerBIServiceAccount -ServicePrincipal -Credential $Credential -TenantId "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx"
    Start-Sleep -s 5
} catch {write-host "Error connecting to Power BI Service."}

$workspace = Get-PowerBIworkspace -name "some-workspace-name"
$dataset = Get-PowerBIDataset -WorkspaceId $workspace.Id
$tablename = "some-table-name"
Remove-PowerBIRow -WorkspaceId $workspace.Id -DataSetId $dataset.Id -TableName $tablename
Add-PowerBIRow -WorkspaceId $workspace.Id -DataSetId $dataset.Id -TableName $tablename -Rows ($report | ConvertTo-Json | ConvertFrom-Json)

This code works perfect locally in powershell core 7.0.3 on my laptop, service principle and all.

But when trying to run it in an Azure Function app, it successfully logs into Power BI using the service principle, and is able to successfully get the workspace specified as well as the dataset. However, once it gets to the Remove-PowerBIRow and Add-PowerBIRow cmdlets, it fails with a generic non descript error:

ERROR: Cannot bind argument to parameter 'InputObject' because it is null. Exception:Type:System.Management.Automation.ParameterBindingValidationExceptionMessage:Cannot bind argument to parameter 'InputObject' because it is null.

Resolve-PowerBIError doesn't give any better information either...

I've tried all different configurations of the commands, explicitly specifying values, pipelining objects in, but it fails the same way every time.

Remove-PowerBIRow -Workspace $workspace -DataSet $dataset -TableName $tablename

$workspace | Remove-PowerBIRow -DataSet $dataset -TableName $tablename

Remove-PowerBIRow -WorkspaceId "xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx" -DataSetId "xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx" -TableName "some-table-name"

How can there be a null parameter if they're explicitly defined in the cmdlet(the 3rd example above) ?????????
all required params for the cmdlet have been defined, it makes no sense.

Every one of the commands above work on my laptop but fail in my Azure Function btw.

I even tried to trace the commands but received no output at all from it in the function app logs:
Trace-Command -Name ParameterBinding -Expression {Remove-PowerBIRow -Workspace $workspace -DataSet $dataset -TableName $tablename} -pshost

I'm lost on this one........

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Remove-PowerBIRow and Add-PowerBIRow calls and reproduce the failure in the Azure Function environment, comparing it with PowerShell Core 7.0.3 locally. Check the parameter-binding and runtime differences around the explicitly supplied workspace, dataset, table, and rows values. Done means identifying the environment-specific null input and confirming the affected cmdlets work in the function app.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, powershell
Domain
cloud, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.