author | ms.service | ms.topic | ms.date | ms.author |
---|---|---|---|---|
ggailey777 |
azure-functions |
include |
03/25/2020 |
glenga |
You can view the queue in the Azure portal or in the Microsoft Azure Storage Explorer. You can also view the queue in the Azure CLI, as described in the following steps:
-
Open the function project's local.setting.json file and copy the connection string value. In a terminal or command window, run the following command to create an environment variable named
AZURE_STORAGE_CONNECTION_STRING
, pasting your specific connection string in place of<MY_CONNECTION_STRING>
. (This environment variable means you don't need to supply the connection string to each subsequent command using the--connection-string
argument.)export AZURE_STORAGE_CONNECTION_STRING="<MY_CONNECTION_STRING>"
$env:AZURE_STORAGE_CONNECTION_STRING = "<MY_CONNECTION_STRING>"
set AZURE_STORAGE_CONNECTION_STRING="<MY_CONNECTION_STRING>"
-
(Optional) Use the
az storage queue list
command to view the Storage queues in your account. The output from this command should include a queue namedoutqueue
, which was created when the function wrote its first message to that queue.az storage queue list --output tsv
-
Use the
az storage message get
command to read the message from this queue, which should be the first name you used when testing the function earlier. The command reads and removes the first message from the queue.echo `echo $(az storage message get --queue-name outqueue -o tsv --query '[].{Message:content}') | base64 --decode`
[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($(az storage message get --queue-name outqueue -o tsv --query '[].{Message:content}')))
az storage message get --queue-name outqueue -o tsv --query [].{Message:content} > %TEMP%out.b64 && certutil -decode -f %TEMP%out.b64 %TEMP%out.txt > NUL && type %TEMP%out.txt && del %TEMP%out.b64 %TEMP%out.txt /q
This script uses certutil to decode the base64-encoded message collection from a local temp file. If there's no output, try removing
> NUL
from the script to stop suppressing certutil output, in case there's an error.
Because the message body is stored base64 encoded, the message must be decoded before it's displayed. After you execute
az storage message get
, the message is removed from the queue. If there was only one message inoutqueue
, you won't retrieve a message when you run this command a second time and instead get an error.