This is a solution for Day 21 of the 25 Days of Serverless.
Get your free Azure account
To run the solution locally, be sure you have installed:
Helpful, "good to have":
- Fork the repo (optional)
- Clone the repo:
git clone https://github.com/JeremyLikness/durable-registry.git
(change to your forked repo if necessary) - Navigate to the
src
directory - Add a
local.settings.json
and configure it to use the emulator:{ "IsEncrypted": false, "Values": { "AzureWebJobsStorage": "UseDevelopmentStorage=true", "FUNCTIONS_WORKER_RUNTIME": "dotnet" } }
- Restore, build, and publish the app in one step, execute
dotnet publish
- Change to the publish directory:
cd bin\Debug\netcoreapp2.2\publish
- Copy the local settings:
cp ../../../../local.settings.json .
- Start the Azure Storage Emulator
- Launch the functions app:
func host start
You can access the APIs directly from your browser or by using your favorite REST client tool (I prefer HTTP-REPL, listed above). All of the solution endpoints use the GET
verb to make the example as easy as possible to use.
http(s)://{endpoint}/api/Open
This will return a unique id. You have 5 minutes from the time you open a registry to add items and/or close it. A closed or timed out registry will not accept new entries.
http(s)://{endpoint}/api/Add/{id}?item={item name}
You will receive 200 - OK
if the registry is valid and open.
http(s)://{endpoint}/api/Finish/{id}
Once closed, you can no longer add items to the registry.
https(s)://{endpoint}/api/Peek/{id}
If a valid registry id is passed, this will return the status (open or closed) and items in the registry.
http(s)://{endpoint}/api/Stats
This will show a count of all registries (open and closed) and a total count of items across all registries.
You can learn more about the solution by reading the related blog post.
👉 Free Durable Functions Hands-on Lab
👉 Durable Functions Documentation
👉 Function Entities Documentation
Regards,