Public/Add-AzTableAPIEntity.ps1

function Add-AzTableAPIEntity {
    <#
    .SYNOPSIS
        Inserts a new entity into an Azure Table Storage table.

    .DESCRIPTION
        Inserts the provided entity. Fails with HTTP 409 if an entity with the
        same PartitionKey and RowKey already exists. Use Set-AzTableAPIEntity
        to insert or replace, or Update-AzTableAPIEntity to merge.

    .PARAMETER Context
        Connection context created by New-AzTableAPIContext.

    .PARAMETER TableName
        Name of the target table.

    .PARAMETER Entity
        Hashtable or PSCustomObject representing the entity to insert.
        Must include PartitionKey and RowKey properties.

    .OUTPUTS
        PSCustomObject representing the inserted entity (as returned by the service).

    .EXAMPLE
        $entity = @{ PartitionKey = 'Sales'; RowKey = '001'; Amount = 99.99 }
        Add-AzTableAPIEntity -Context $ctx -TableName 'Orders' -Entity $entity
    #>

    [CmdletBinding()]
    [OutputType([PSCustomObject])]
    param (
        [Parameter(Mandatory)]
        [ValidateScript({
            ($_.PSObject.Properties.Name -contains 'Endpoint') -and
            ($_.PSObject.Properties.Name -contains 'AuthType')
        }, ErrorMessage = 'The -Context parameter requires a context object created by New-AzTableAPIContext.')]
        [PSCustomObject]$Context,

        [Parameter(Mandatory)]
        [ValidateNotNullOrEmpty()]
        [string]$TableName,

        [Parameter(Mandatory)]
        [ValidateNotNull()]
        [object]$Entity
    )

    $null = Get-AzTableEntityKey -Entity $Entity

    $response = Invoke-AzTableRestMethod -Context $Context -Method 'POST' -Resource $TableName -Body $Entity
    return $response.Content
}