是否可以在azure上创建新的表存储,只使用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()
不喜欢这种方式..
答案 0 :(得分:1)
如果您使用的是Azure PowerShell Cmdlet,则可以使用New-AzureStorageTable
来创建新表。
示例代码:
$storageContext = New-AzureStorageContext -StorageAccountName "accountname" -StorageAccountKey "accountkey"
New-AzureStorageTable -Name "TableName" -Context $storageContext