Private/Get-SpecCloudTable.ps1

Function Get-SpecCloudTable {
    [CmdletBinding()]
    Param (
        [Parameter(Mandatory=$true)]
        [String]$tableStorageAccount,

        [Parameter(Mandatory=$true)]
        [String]$tableResourceGroup,

        [Parameter(Mandatory=$true)]
        [String]$TableName        
    )    

    try {
        $storageAccount = Get-AzStorageAccount -ResourceGroupName $tableresourceGroup -Name $tablestorageAccount -ErrorAction Stop
        $ctx = $storageAccount.Context
    } catch {
        Write-Warning "Unable to locate storage account: $tableStorageAccount. Are you sure it exists?"
        return 501
    }
    
    try {
        $storageTable = Get-AzStorageTable -Name $TableName -Context $ctx -ErrorAction Stop
        $cloudTable = $storageTable.CloudTable
    } catch {
        Write-Warning "Unable to locate table: $TableName. Are you sure it exists?"
        return 502
    }

    return $cloudTable
}