-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CosmosDB function to log changes works local, config for prod added b…
…ut not tested
- Loading branch information
Showing
6 changed files
with
68 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
handlenett-backend/serverless/functions/ItemsChangeFeed.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Microsoft.Azure.Functions.Worker; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace HandlenettNotifications | ||
{ | ||
public class ItemsChangeFeed | ||
{ | ||
private readonly ILogger _logger; | ||
|
||
public ItemsChangeFeed(ILoggerFactory loggerFactory) | ||
{ | ||
_logger = loggerFactory.CreateLogger<ItemsChangeFeed>(); | ||
} | ||
|
||
[Function("ItemsChangeFeed")] | ||
public void Run([CosmosDBTrigger( | ||
databaseName: "Handlenett", | ||
containerName: "ShoppingListItems", | ||
Connection = "ConnectionStrings--AzureFunctionsCosmosDB", | ||
LeaseContainerName = "leases", | ||
CreateLeaseContainerIfNotExists = true)] IReadOnlyList<MyDocument> input) | ||
{ | ||
|
||
if (input != null && input.Count > 0) | ||
{ | ||
_logger.LogInformation("Documents modified: " + input.Count); | ||
_logger.LogInformation("First document Id: " + input[0].id); | ||
} | ||
} | ||
} | ||
|
||
public class MyDocument | ||
{ | ||
public string id { get; set; } | ||
Check warning on line 36 in handlenett-backend/serverless/functions/ItemsChangeFeed.cs GitHub Actions / build-and-deploy
|
||
|
||
public string Text { get; set; } | ||
Check warning on line 38 in handlenett-backend/serverless/functions/ItemsChangeFeed.cs GitHub Actions / build-and-deploy
|
||
|
||
public int Number { get; set; } | ||
|
||
public bool Boolean { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,5 @@ | |
}) | ||
.Build(); | ||
|
||
|
||
host.Run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters