query messages

pull/2/head
bgarcia 2021-12-03 10:41:27 +01:00
parent d09b63dfa1
commit dd6107c315
2 changed files with 39 additions and 0 deletions

View File

@ -0,0 +1,31 @@
Param(
[parameter(Mandatory=$true)][string]$storageAccount,
[parameter(Mandatory=$true)][string]$accesskey
)
function GetMessages($storageAccount, $accesskey){
$method = "GET"
$contenttype = "application/x-www-form-urlencoded"
$version = "2017-04-17"
$resource = "$QueueName/?comp=metadata"
$queue_url = "https://$storageAccount.queue.core.windows.net/$resource"
$GMTTime = (Get-Date).ToUniversalTime().toString('R')
$canonheaders = "x-ms-date:$GMTTime`nx-ms-version:$version`n"
$stringToSign = "$method`n`n$contenttype`n`n$canonheaders/$storageAccount/$resource"
$hmacsha = New-Object System.Security.Cryptography.HMACSHA256
$hmacsha.key = [Convert]::FromBase64String($accesskey)
$signature = $hmacsha.ComputeHash([Text.Encoding]::UTF8.GetBytes($stringToSign))
$signature = [Convert]::ToBase64String($signature)
$headers = @{
'x-ms-date' = $GMTTime
Authorization = "SharedKeyLite " + $storageAccount + ":" + $signature
"x-ms-version" = $version
Accept = "text/xml"
}
$response = Invoke-WebRequest -Method $method -Uri $queue_url -Headers $headers -ContentType $contenttype
return $response.Headers["x-ms-approximate-messages-count"]
}
$messageCount = GetMessages -storageAccount $storageAccount -accesskey $accesskey
Write-Output "Feed Queue Messages: $messageCount"

View File

@ -89,6 +89,14 @@ This folder contains additional scripts needed for testing the Azure Container A
sleep 2;
}
```
```ps1
while (1) {
$output = ./MessageCount.ps1 -storageAccount <storageAccountName> -accessKey <accessKey>
clear;
echo $output;
sleep 1;
}
```
![Initial replicas](./scale-out-demo-0.png)