I created Event Grid subscription on Azure Blob Storage that sends message to Azure Queue every time a blob is created/modified. The message is inserted with default TTL, which is 7 days. Is there a way to change this parameter? I'd like to extend the expiration time to at least 14 days.
There is no way from the AEG subscription to change any property of the message sent to the event handler resource.
However, as a workaround for that, can be used the EventGridTrigger function with a CloudQueue output binding to the storage queue.
The following code snippet is an example of the EventGridTrigger function for your solution:
run.csx:
#r "Newtonsoft.Json"
#r "Microsoft.WindowsAzure.Storage"
using Microsoft.WindowsAzure.Storage.Queue;
using Microsoft.WindowsAzure.Storage;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
public static async Task Run(JObject eventGridEvent, CloudQueue outputQueue, ILogger log)
{
log.LogInformation(eventGridEvent.ToString());
await outputQueue.AddMessageAsync(new CloudQueueMessage(eventGridEvent.ToString()),
TimeSpan.FromDays(14), // TTL
TimeSpan.FromSeconds(0),
new QueueRequestOptions(),
new OperationContext());
}
function.json:
{
"bindings": [
{
"type": "eventGridTrigger",
"name": "eventGridEvent",
"direction": "in"
},
{
"name": "outputQueue",
"type": "queue",
"direction": "out",
"queueName": "test",
"connection": "myaccount_STORAGE"
}
]
}