This repository was archived by the owner on Jul 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
src/ServiceLayer.Mesh/Functions Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,6 @@ namespace ServiceLayer.Mesh.Functions
1212 public class DiscoveryFunction
1313 {
1414 private readonly ILogger _logger ;
15-
1615 private readonly IMeshInboxService _meshInboxService ;
1716 private readonly ServiceLayerDbContext _serviceLayerDbContext ;
1817
@@ -28,7 +27,10 @@ public async Task Run([TimerTrigger("0 */1 * * * *")] TimerInfo myTimer)
2827 {
2928 _logger . LogInformation ( $ "C# Timer trigger function executed at: { DateTime . Now } ") ;
3029
31- var response = await _meshInboxService . GetMessagesAsync ( Environment . GetEnvironmentVariable ( "MailboxId" ) ) ;
30+ var mailboxId = Environment . GetEnvironmentVariable ( "MailboxId" )
31+ ?? throw new InvalidOperationException ( $ "Environment variable 'MailboxId' is not set or is empty.") ;
32+
33+ var response = await _meshInboxService . GetMessagesAsync ( mailboxId ) ;
3234
3335 if ( response . Response . Messages . Count ( ) > 500 )
3436 {
@@ -47,15 +49,16 @@ public async Task Run([TimerTrigger("0 */1 * * * *")] TimerInfo myTimer)
4749 {
4850 FileId = messageId ,
4951 FileType = "" ,
50- MailboxId = Environment . GetEnvironmentVariable ( "MailboxId" ) ,
52+ MailboxId = mailboxId ,
5153 Status = "Discovered"
5254 } ;
5355
54- _serviceLayerDbContext . MeshFiles . Add ( meshFile ) ;
56+ await _serviceLayerDbContext . MeshFiles . AddAsync ( meshFile ) ;
57+ await _serviceLayerDbContext . SaveChangesAsync ( ) ;
5558
5659 QueueClient queueClient ;
5760
58- if ( Environment . GetEnvironmentVariable ( "ASPNETCORE_ENV " ) == "Dev " )
61+ if ( Environment . GetEnvironmentVariable ( "ASPNETCORE_ENVIRONMENT " ) == "Development " )
5962 {
6063 queueClient = new QueueClient ( "UseDevelopmentStorage=true" , "my-local-queue" ) ;
6164 }
You can’t perform that action at this time.
0 commit comments