Public/Remove-AzTableAPIEntity.ps1
|
function Remove-AzTableAPIEntity { <# .SYNOPSIS Deletes an entity from an Azure Table Storage table. .PARAMETER Context Connection context created by New-AzTableAPIContext. .PARAMETER TableName Name of the table containing the entity. .PARAMETER PartitionKey PartitionKey of the entity to delete. .PARAMETER RowKey RowKey of the entity to delete. .PARAMETER ETag Optional ETag for optimistic concurrency. Defaults to '*' (unconditional). .EXAMPLE Remove-AzTableAPIEntity -Context $ctx -TableName 'Orders' -PartitionKey 'Sales' -RowKey '001' .EXAMPLE Remove-AzTableAPIEntity -Context $ctx -TableName 'Orders' -PartitionKey 'Sales' -RowKey '001' -WhatIf #> [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')] 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)] [ValidateNotNullOrEmpty()] [string]$PartitionKey, [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [string]$RowKey, [string]$ETag = '*' ) $target = "$TableName / PartitionKey='$PartitionKey', RowKey='$RowKey'" if ($PSCmdlet.ShouldProcess($target, 'Remove entity from Azure Table Storage')) { $resource = Format-AzTableEntityResource -TableName $TableName -PartitionKey $PartitionKey -RowKey $RowKey Invoke-AzTableRestMethod -Context $Context -Method 'DELETE' -Resource $resource -ETag $ETag | Out-Null } } |