Instantly share code, notes, and snippets.

Embed
What would you like to do?
Query Azure Table Storage using PowerShell. Associated Blog Post https://blog.darrenjrobinson.com/loading-and-querying-data-in-azure-table-storage-using-powershell/
$storageAccountName = "myStorageAccount"
$storageAccountkey = "abcdefghi123456789YUoxr5mqAmTRgeXSh6Vvx6q+O6aiV9pMaCYbrUo1x/Abcdeb=="
$tableName = "NICVendors"
$apiVersion = "2017-04-17"
$tableURL = "https://$($storageAccountName).table.core.windows.net/$($tableName)"
$GMTime = (Get-Date).ToUniversalTime().toString('R')
$string = "$($GMTime)`n/$($storageAccountName)/$($tableName)"
$hmacsha = New-Object System.Security.Cryptography.HMACSHA256
$hmacsha.key = [Convert]::FromBase64String($storageAccountkey)
$signature = $hmacsha.ComputeHash([Text.Encoding]::UTF8.GetBytes($string))
$signature = [Convert]::ToBase64String($signature)
$headers = @{
Authorization = "SharedKeyLite " + $storageAccountName + ":" + $signature
Accept = "application/json;odata=fullmetadata"
'x-ms-date' = $GMTime
"x-ms-version" = $apiVersion
}
$queryURL = "$($tableURL)?`$filter=(Vendor eq 'Dell Inc.')"
$NICitem = Invoke-RestMethod -Method GET -Uri $queryURL -Headers $headers -ContentType application/json
$NICitem.value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment