I have a script where I dayly check if there are messages on the Azure Storage Account Queue. It was always working, but now not anymore. I dont receive errors. What is going wrong?
Here is my script:
$queueUsername = "SomeGUID"
$queuePassword= "SomeGUID"
[securestring]$secStringQueuePassword = ConvertTo-SecureString $queuePassword -AsPlainText -Force
$queueCredential = New-Object System.Management.Automation.PSCredential ($queueUserName, $secStringQueuePassword)
$message = $null
$queuemessage = $null
$resourceGroup = 'someResourceGroupName'
$storageAccountName = "someStorageAccountName"
$queueName = "someQueueName"
$accessKey = "someKey"
$storageContext = New-AzStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $accessKey
$queue = Get-AzStorageQueue -Context $storageContext -Name $queueName
$invisibleTimeout = [System.TimeSpan]::FromSeconds(10)
$queueMessage = $queue.CloudQueue.GetMessageAsync($invisibleTimeout,$null,$null)
if ($null -ne $queuemessage.result.asstring) {
$message = $queueMessage.result.AsString
$queue.CloudQueue.DeleteMessageAsync($queueMessage.Result.Id,$queueMessage.Result.popReceipt)
Clear-AzContext -Force
"Found item on the queue"
$message | convertfrom-json
}
else {
Clear-AzContext -Force
"No item on the queue"
}
I clicked on "Empty queue" and now it is working fine. It looks like there were some dequeue messages in the queue which were the problem.