24 lines
1.3 KiB
PowerShell
24 lines
1.3 KiB
PowerShell
$ManagedIdentityClientId = "612223b3-b7ae-4433-b09f-480e9aef2287"
|
|
$SubscriptionName = "core"
|
|
$ResourceGroupName = "groupmanager-t-rg"
|
|
$StorageAccountName = "wndshgroupmanagertv1sa"
|
|
$MaxMessages = 32
|
|
|
|
$null = Disable-AzContextAutosave -Scope Process
|
|
$null = Connect-AzAccount -Identity -AccountId $ManagedIdentityClientId -Subscription $SubscriptionName
|
|
$null = Set-AzCurrentStorageAccount -ResourceGroupName $ResourceGroupName -Name $StorageAccountName
|
|
# Get-AzStorageQueue complains (https://go.microsoft.com/fwlink?linkid=2258844), but it's the recommended method of getting messages... (https://learn.microsoft.com/azure/storage/queues/storage-powershell-how-to-use-queues#retrieve-a-queue)
|
|
$null = Update-AzConfig -DisplaySecretsWarning $false
|
|
|
|
$StorageQueue = (Get-AzStorageQueue -Name "members").QueueClient
|
|
Write-Output "QueueClient.PeekMessages..."
|
|
$Queue = $StorageQueue.PeekMessages($MaxMessages)
|
|
Write-Output "QueueClient.PeekMessages!"
|
|
if (-NOT $Queue.HasValue -or $Queue.Value.Count -eq 0) {
|
|
Write-Output "No messages to process."
|
|
return
|
|
}
|
|
Write-Output "Queue.HasValue!"
|
|
Write-Output "Messages..."
|
|
$Messages = $Queue.Value.ForEach{[Convert]::FromBase64String($_.MessageText)}.ForEach{[Text.Encoding]::UTF8.GetString($_)}
|
|
Write-Output "Messages $(Measure-Object $Messages)!" |