I'm wondering if it is possible to use a SAS token for the authorization header in a REST API call to Azure Tables using PowerShell. I've created a test Account SAS and tried passing the actual token value starting with the "sr=" tag and also the full URI however I'm getting the following error:
Invoke-RestMethod : AuthenticationFailed Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
$resource = "$tableName(PartitionKey='$domain',RowKey='$apiKey')"
$tableUrl = "https://$storageAccount.table.core.windows.net/$resource"
$sasReadToken = "SharedAccessSignature ?sv=2017-07-29&ss=t&srt=o&sp=r&se=2019-03-07T02:37:08Z&st=2018-03-06T18:37:08Z&spr=https&sig=<removed>"
$GMTTime = (Get-Date).ToUniversalTime().toString('R')
$header = @{
Authorization = $sasReadToken;
'x-ms-date' = $GMTTime;
Accept = "application/json;odata=fullmetadata";
}
$result = Invoke-RestMethod -Uri $tableUrl -Headers $header -Method Get -Verbose
While I realize there is an AzureRm module to handle some of this, I don't want to install unnecessary libraries on the host PC. Is this even possible?
NOTE: The signature has been removed in my example.