Arcus.Scripting.Storage.Table.psm1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<#
 .Synopsis
  Create a Azure Table Storage within an Azure Storage Account.
 
 .Description
  (Re)Create a Azure Table Storage within an Azure Storage Account.

 .Parameter ResourceGroupName
  The resource group where the Azure Storage Account is located.

 .Parameter StorageAccountName
  The name of the Azure Storage Account to add the table to.

 .Parameter TableName
  The name of the table to add on the Azure Storage Account.

 .Parameter Recreate
  The optional flag to indicate whether or not a possible already existing table should be deleted and re-created.

 .Parameter RetryIntervalSeconds
  The optional amount of seconds to wait each retry-run when a failure occures during the re-creating process.

 .Parameter MaxRetryCount
  The optional maximum amount of retry-runs should happen when a failure occurs during the re-creating process.
#>

function Create-AzStorageTable {
    param(
       [Parameter(Mandatory = $true)][string] $ResourceGroupName = $(throw "Name of resource group is required"),
       [Parameter(Mandatory = $true)][string] $StorageAccountName = $(throw "Name of Azure storage account is required"),
       [Parameter(Mandatory = $true)][string] $TableName = $(throw "Name of Azure table is required"),
       [Parameter()][switch] $Recreate = $false,
       [Parameter(Mandatory = $false)][int] $RetryIntervalSeconds = 5,
       [Parameter(Mandatory = $false)][int] $MaxRetryCount = 10
    )

    if ($Recreate) {
        . $PSScriptRoot\Scripts\Create-AzTableStorageAccountTable.ps1 `
            -ResourceGroupName $ResourceGroupName `
            -StorageAccountName $StorageAccountName `
            -TableName $TableName `
            -Recreate `
            -RetryIntervalSeconds $RetryIntervalSeconds `
            -MaxRetryCount $MaxRetryCount
    } else {
        . $PSScriptRoot\Scripts\Create-AzTableStorageAccountTable.ps1 `
            -ResourceGroupName $ResourceGroupName `
            -StorageAccountName $StorageAccountName `
            -TableName $TableName `
            -RetryIntervalSeconds $RetryIntervalSeconds `
            -MaxRetryCount $MaxRetryCount
    }
}

Export-ModuleMember -Function Create-AzStorageTable