Skip to content

Files

Latest commit

 

History

History
64 lines (43 loc) · 3.17 KB

functions-add-output-binding-view-queue-cli.md

File metadata and controls

64 lines (43 loc) · 3.17 KB
author ms.service ms.topic ms.date ms.author ms.custom
ggailey777
azure-functions
include
06/10/2022
glenga
devdivchpfy22

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:

  1. 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, and paste 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>"
    

  2. (Optional) Use the az storage queue list command to view the Storage queues in your account. The output from this command must include a queue named outqueue, which was created when the function wrote its first message to that queue.

    az storage queue list --output tsv
    
  3. Use the az storage message get command to read the message from this queue, which should be the value you supplied 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 in outqueue, you won't retrieve a message when you run this command a second time and instead get an error.