Shane
Shane

Reputation: 379

Azure function set expiration time for queue output

Is it possible to set an expiration time for Azure Function Storage queue output binding?

This is what I have in function.js:

{ "type": "queue", "name": "MyMessageQueue", "queueName": "mymsgqueue", "connection": "AzureWebJobsStorage", "direction": "out" }

However can I specify when the message I add should expire?

Upvotes: 0

Views: 1252

Answers (1)

Vassili Altynikov
Vassili Altynikov

Reputation: 2059

Yes, you can. In your function's Run method, change the MyMessageQueue output parameter type to CloudQueue. Then create a CloudQueueMessage in your code and use the AddMessage method to add the message to the queue. The timeToLive parameter would allow you to control the expiration time.

Refer to the Azure Functions Queue Storage bindings documentation page for more details and examples.

Upvotes: 2

Related Questions