Private/Get-AzTableEntityKeys.ps1

function Get-AzTableEntityKey {
    <#
    .SYNOPSIS
        Extracts and validates PartitionKey and RowKey values from an entity object.
    #>

    [CmdletBinding()]
    param (
        [Parameter(Mandatory)]
        [ValidateNotNull()]
        [object]$Entity,

        [string]$ErrorMessage = 'Entity must have non-empty PartitionKey and RowKey properties.'
    )

    $partitionKey = if ($Entity -is [hashtable]) { $Entity['PartitionKey'] } else { $Entity.PartitionKey }
    $rowKey = if ($Entity -is [hashtable]) { $Entity['RowKey'] } else { $Entity.RowKey }

    if ([string]::IsNullOrEmpty($partitionKey) -or [string]::IsNullOrEmpty($rowKey)) {
        throw $ErrorMessage
    }

    return [PSCustomObject]@{
        PartitionKey = $partitionKey
        RowKey       = $rowKey
    }
}