title: Trying to get multiple messages from an Azure Storage Queue
body: <p>I have a node.js Function App which I'm trying to use to retrieve a specific message from a storage queue in order to delete it. It doesnt seem like there is a method to get a specific message by ID, so I'm trying to read all the messages, or at least 32 of them, then find the message to delete by ID.</p>
  <p>My problem is I cant seem to figure out how to format the request to specify the number of messages to receive. I am trying to add the option &quot;numberOfMessages&quot; based on this documentation: <a href="https://docs.microsoft.com/en-us/javascript/api/@azure/storage-queue/queuereceivemessageoptions?view=azure-node-latest#@azure-storage-queue-queuereceivemessageoptions-customheaders" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/javascript/api/@azure/storage-queue/queuereceivemessageoptions?view=azure-node-latest#@azure-storage-queue-queuereceivemessageoptions-customheaders</a></p>
  <p>Here is what I have right now that isn't working:</p>
  <pre><code>const response = await queueClient.receiveMessages({&quot;numberOfMessages&quot;: 32});
  context.log(&quot;response: &quot; + JSON.stringify(response.receivedMessageItems));
  context.log(&quot;received messages length: &quot; + response.receivedMessageItems.length);
  </code></pre>
  <p>response is:</p>
  <pre><code>[Information] response: [{&quot;messageId&quot;:&quot;XXXXXX&quot;,&quot;insertedOn&quot;:&quot;2022-08-28T06:12:45.000Z&quot;,&quot;expiresOn&quot;:&quot;2022-09-04T06:12:45.000Z&quot;,&quot;popReceipt&quot;:&quot;XXXXXXXXX&quot;,&quot;nextVisibleOn&quot;:&quot;2022-08-30T14:57:37.000Z&quot;,&quot;dequeueCount&quot;:858,&quot;messageText&quot;:&quot;XXXXXXX&quot;}]
  [Information] received messages length: 1
  </code></pre>
  <p>How should I be formatting the option(s)???</p>
  <p>edit:</p>
  <p>Here is the complete code of index.js in my function app (with redactions):</p>
  <pre><code>module.exports = async function (context, req) {
    context.log('JavaScript HTTP trigger function processed a request.');
    const message = req.body;
    const ackType = message.ackType;
  
    if (ackType == 1){
        const { QueueServiceClient, StorageSharedKeyCredential } = require(&quot;@azure/storage-queue&quot;);
  
        const account = &quot;MY_ACCOUNT_NAME&quot;;
        const accountKey = &quot;MY_ACCOUNT_KEY&quot;;
  
        const sharedKeyCredential = new StorageSharedKeyCredential(account, accountKey);
        const queueServiceClient = new QueueServiceClient(
            `https://${account}.queue.core.windows.net`,
            sharedKeyCredential,
            {
            retryOptions: { maxTries: 4 } // Retry options
            }
        );
        
        const queueName = &quot;MY_QUEUE_NAME&quot;;
  
        const queueClient = queueServiceClient.getQueueClient(queueName);
        const response = await queueClient.receiveMessages({&quot;numofmessages&quot;: 32});
        context.log(&quot;response: &quot; + JSON.stringify(response));
        context.log(&quot;receivedMessageItems: &quot; + JSON.stringify(response.receivedMessageItems));
        context.log(&quot;received messages length: &quot; + response.receivedMessageItems.length);
    }
  
    context.res = {
        status: 200 /* Defaults to 200 */
    };
  }
  </code></pre>
  <p>Here is the queue I am connecting to:
  <a href="https://i.stack.imgur.com/JLD0f.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JLD0f.png" alt="enter image description here" /></a></p>