Last active
December 4, 2020 14:52
-
-
Save darrenjrobinson/df83178fb7247fa3e5891c4286027625 to your computer and use it in GitHub Desktop.
Query Azure Table Storage using PowerShell. Associated Blog Post https://blog.darrenjrobinson.com/loading-and-querying-data-in-azure-table-storage-using-powershell/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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