-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathCleanupAzureBlobStorageSnippetsFunction.cs
More file actions
33 lines (29 loc) · 1.17 KB
/
CleanupAzureBlobStorageSnippetsFunction.cs
File metadata and controls
33 lines (29 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using MediatR;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using ByteSync.ServerCommon.Commands.Storage;
using Microsoft.Azure.Functions.Worker;
namespace ByteSync.Functions.Timer;
public class CleanupAzureBlobStorageSnippetsFunction
{
private readonly ILogger<CleanupAzureBlobStorageSnippetsFunction> _logger;
private readonly IMediator _mediator;
public CleanupAzureBlobStorageSnippetsFunction(IConfiguration configuration, IMediator mediator,
ILogger<CleanupAzureBlobStorageSnippetsFunction> logger)
{
_mediator = mediator;
_logger = logger;
}
[Function("CleanupBlobFilesFunction")]
public async Task<int> RunAsync([TimerTrigger("0 0 0 * * *"
#if DEBUG
, RunOnStartup= true
#endif
)] TimerInfo myTimer)
{
_logger.LogInformation("Cleanup Azure BlobStorage Function started at: {Now}", DateTime.Now);
var deletedBlobsCount = await _mediator.Send(new CleanupAzureBlobStorageSnippetsRequest());
_logger.LogInformation("Cleanup Azure BlobStorage Function - Deletion complete, {Deleted} element(s)", deletedBlobsCount);
return deletedBlobsCount;
}
}