Private/New-AzTable.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Function New-AzTable {
    [CmdletBinding()]
    
    Param(
        [parameter(Mandatory = $true)]
        [string]
        $connString,

        [parameter(Mandatory = $true)]
        [string]
        $tableName
    )

    # create table
    $storageAccount = [Microsoft.Azure.Cosmos.Table.CloudStorageAccount]::Parse($connString)
    $TableClient = [Microsoft.Azure.Cosmos.Table.CloudTableClient]::new($storageAccount.TableEndpoint, $storageAccount.Credentials)
    $Table = [Microsoft.Azure.Cosmos.Table.CloudTable]$TableClient.GetTableReference($TableName)
    $Table.CreateIfNotExists() | Out-Null
    Return $Table
}