Netha
Netha

Reputation: 1

How create table storage with only connection string on powerShell?

is it possible create new table storage on azure with only use connection string by PowerShell?

Param (
[string]$StorageAccountName,
[string]$StorageAccountKey,
[string]$name
)

Import-Module Azure

$tableName =  $name

$accountCredentials = New-Object "Microsoft.WindowsAzure.Storage.Auth.StorageCredentials" $StorageAccountName, $StorageAccountKey
$storageAccount = New-Object "Microsoft.WindowsAzure.Storage.CloudStorageAccount" $accountCredentials, $true

$tableClient = $storageAccount.CreateCloudTableClient()
$table = $tableClient.GetTableReference($tableName)

$table.CreateIfNotExists()

not like this way..

Upvotes: 0

Views: 482

Answers (1)

Gaurav Mantri
Gaurav Mantri

Reputation: 136256

If you are using Azure PowerShell Cmdlets, there is a New-AzureStorageTable that you can use to create a new table.

Sample Code:

$storageContext = New-AzureStorageContext -StorageAccountName "accountname" -StorageAccountKey "accountkey"
New-AzureStorageTable -Name "TableName" -Context $storageContext

Upvotes: 1

Related Questions