Closed pawp81 closed 4 years ago
Hi @pawp81, I was running into the exact same issue and it turned out to be an empty object being inserted into the properties of the $entity, which caused the error. If you're still experiencing the issue, make sure all your elements aren't null (My problem got solved inserting empty strings)
Cheers
@penicaudm Indeed it was empty object. However, rows that I want to insert to Storage Table might have empty columns. How to insert those columns that have values and for empty column insert NULL?
I believe you meant insert empty string if value is null for a specified property?
My code looks like this, with the issue being phone numbers were often null.
$properties = @{
CustomerID = $CustomerID
DomainName = $CustomerName
Domain = $Customerdomain
PrimaryContactEmail = $CustomerAgreement.PrimaryContact.Email
PrimaryContactFirstName = $CustomerAgreement.PrimaryContact.FirstName
PrimaryContactLastName = $CustomerAgreement.PrimaryContact.LastName
PrimaryContactPhoneNumber = if ($null -ne $CustomerAgreement.PrimaryContact.PhoneNumber) { $CustomerAgreement.PrimaryContact.PhoneNumber } else { "" }
DateSigned = (Get-Date -format "dd/MM/yyyy" -Date $CustomerAgreement.DateAgreed)
Type = $CustomerAgreement.Type
}
Add-AzTableRow -property $properties -rowkey $rowkey -partitionkey (New-Guid) -table $Table
I also had to insert nearly empty rows, in which case my code is something like:
$properties = @{
CustomerID = $CustomerID
DomainName = $CustomerName
Domain = $Customerdomain
PrimaryContactEmail = ""
PrimaryContactFirstName = ""
PrimaryContactLastName = ""
PrimaryContactPhoneNumber = ""
DateSigned = "Not yet signed"
Type = $CustomerAgreement.Type
}
As far as I know, the value of a property cannot be $null, and instead you should use an empty string.
Describe the bug Error when running Add-AzTableRow to add new entry to Azure Table Storage
Error Message Exception calling "Execute" with "1" argument(s): "Object reference not set to an instance of an object." At C:\Program Files\WindowsPowerShell\Modules\AzureRmStorageTable\2.0.2\AzureRmStorageTableCoreHelper.psm1:239 char:10
PowerShell Version Include here the full output of the following command line: