简体   繁体   中英

Powershell List all tables on Azure Storage

I am trying to automate a query from tables on various Azure Storages. The tables are automatically generated with a different name every week

I am looking for a way to automatically generate a list of the tables available on a given storage and then I can use the foreach() function to query each table.

I've seen a few bits of scripts here and there but cannot get something effective for example:

$response = Invoke-WebRequest -Uri 'https://MyAccountName.table.core.windows.net/Tables/'
[xml]$tables = $response.Content
$tableNames = $tables.feed.entry.content.properties.TableName

To fetch the list of tables in your storage account you can use Azure PowerShell Cmdlets. There's absolutely no need to do it via consuming REST API. The Cmdlet you would want to use is Get-AzureStorageTable .

Here's a sample code:

$StorageAccountName = "your storage account name"
$StorageAccountKey = "your storage account key"
$ctx = New-AzureStorageContext -StorageAccountName $StorageAccountName -StorageAccountKey $StorageAccountKey
Get-AzureStorageTable -Context $ctx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM