You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Where <app> is one of the executable app namespace, e.g. `time_tracker_api`.
42
+
Where <app> is one of the executable app namespace, e.g. `time_tracker_api` or `time_tracker_events`.
42
43
The `stage` can be
43
44
44
45
* `dev`: Used for working locally
@@ -66,6 +67,40 @@ automatically [pip](https://pip.pypa.io/en/stable/) as well.
66
67
- Open `http://127.0.0.1:5000/` in a browser. You will find in the presented UI
67
68
a link to the swagger.json with the definition of the api.
68
69
70
+
#### Handling Cosmos DB triggers for creating events with time_tracker_events
71
+
The project `time_tracker_events` is an Azure Function project. Its main responsibility is to respond to calls related to
72
+
events, like those [triggered by Change Feed](https://docs.microsoft.com/en-us/azure/cosmos-db/change-feed-functions).
73
+
Every time a write action (`create`, `update`, `soft-delete`) is done by CosmosDB, thanks to [bindings](https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-cosmosdb?toc=%2Fazure%2Fcosmos-db%2Ftoc.json&bc=%2Fazure%2Fcosmos-db%2Fbreadcrumb%2Ftoc.json&tabs=csharp)
74
+
these functions will be called. You can also run them in your local machine:
75
+
76
+
- You must have the [Azure CLI](https://docs.microsoft.com/en-us/cli/azure/get-started-with-azure-cli?view=azure-cli-latest)
77
+
and the [Azure Functions Core Tools](https://docs.microsoft.com/en-us/azure/azure-functions/functions-run-local?tabs=macos%2Ccsharp%2Cbash)
78
+
installed in your local machine.
79
+
- Be sure to [authenticate](https://docs.microsoft.com/en-us/cli/azure/authenticate-azure-cli?view=azure-cli-latest)
80
+
with the Azure CLI if you are not.
81
+
```bash
82
+
az login
83
+
```
84
+
- Execute the project
85
+
```bash
86
+
cd time_tracker_events
87
+
source run.sh
88
+
```
89
+
You will see that a large console log will appear ending with a message like
90
+
```log
91
+
Now listening on: http://0.0.0.0:7071
92
+
Application started. Press Ctrl+C to shut down.
93
+
```
94
+
- Now you are ready to start generating events. Just execute any change in your API and you will see how logs are being
95
+
generated by the console app you ran before. For instance, this is the log generated when I restarted a time entry:
96
+
```log
97
+
[04/30/2020 14:42:12] Executing 'Functions.handle_time_entry_events_trigger' (Reason='New changes on collection time_entry at 2020-04-30T14:42:12.1465310Z', Id=3da87e53-0434-4ff2-8db3-f7c051ccf9fd)
98
+
[04/30/2020 14:42:12] INFO: Received FunctionInvocationRequest, request ID: 578e5067-b0c0-42b5-a1a4-aac858ea57c0, function ID: c8ac3c4c-fefd-4db9-921e-661b9010a4d9, invocation ID: 3da87e53-0434-4ff2-8db3-f7c051ccf9fd
for making `time_tracker_events` to handle the triggers [generated by our Cosmos DB database throw Change Feed](https://docs.microsoft.com/bs-latn-ba/azure/cosmos-db/change-feed-functions).
0 commit comments