title: Azure Function used to write to queue - can I set metadata?
body: <p>I can see from <a href="https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-queue" rel="nofollow noreferrer">this page</a> that you can access a queue message metadata properties simply enough when they are used as a trigger, but I want to do the opposite.
  I have an Azure function which writes messages to a queue, but it current has the default Expiration Time and I want to set a much shorter expiration time so they only live on the queue for a very short period.</p>
  
  <p>Is there a way when writing the message to the queue from the Azure Function to set the Expiration time?</p>
  
  <p>Thanks</p>
  
  <p><strong>EDIT 1:</strong>
  One caveat is that I dont know the name of the queue ahead of time. That is part of the incoming message, so the queuename is set as a parameter of the output binding
  I made the change as recommended by @Mikhail. Here is the function as it stands:</p>
  
  <pre><code>#r "Microsoft.WindowsAzure.Storage"
  #r "Newtonsoft.Json"
  
  using System;
  using Microsoft.WindowsAzure.Storage.Queue;
  using Newtonsoft.Json;
  
  public static void Run(MyType myEventHubMessage, CloudQueue outputQueue, TraceWriter log)
  {
      var deviceId = myEventHubMessage.DeviceId;
      var data = JsonConvert.SerializeObject(myEventHubMessage);
      var msg = new CloudQueueMessage(data);
      log.Info($"C# Event Hub trigger function processed a message: {deviceId}");
      outputQueue.AddMessage(msg, TimeSpan.FromMinutes(3), null, null, null);
  
  }
  
  public class MyType
  {
    public string DeviceId { get; set; }
    public double Field1{ get; set; }
    public double Field2 { get; set; }
    public double Field3 { get; set; }
  }
  </code></pre>
  
  <p>And the output binding in my function.json:</p>
  
  <pre><code>{
  "type": "CloudQueue",
  "name": "$return",
  "queueName": "{DeviceId}",
  "connection": "myConn",
  "direction": "out"
  }
  </code></pre>