Public/New-AzTableAPITable.ps1
|
function New-AzTableAPITable { <# .SYNOPSIS Creates a new table in Azure Table Storage. .PARAMETER Context Connection context created by New-AzTableAPIContext. .PARAMETER TableName Name of the table to create. Must be 3-63 characters, start with a letter, and contain only alphanumeric characters (enforced by parameter validation). .OUTPUTS PSCustomObject representing the newly created table. .EXAMPLE $table = New-AzTableAPITable -Context $ctx -TableName 'Orders' #> [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'Medium')] [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()] [ValidateLength(3, 63)] [ValidatePattern('^[A-Za-z][A-Za-z0-9]*$')] [string]$TableName ) if ($PSCmdlet.ShouldProcess($TableName, 'Create Azure Table Storage table')) { $body = @{ TableName = $TableName } $response = Invoke-AzTableRestMethod -Context $Context -Method 'POST' -Resource 'Tables' -Body $body return $response.Content } } |