As I where creating the Kudos feature for this blog, I needed to check if a visitor already has given kudos to an article before. An easy way to do that (in my mind) is to randomly generate a GUID and store that in the browser to somehow recognize the browser/visitor again.
But all articles, blogs and SO post on handling cookies in ASP.Net Core all focus on dependency inject the IHttpContextAccessor or use the HttpResponse property on the ASP.Net Core controller it self to gain access to the ResponseCookies. None of these methods works out of the box in Azure Functions! 🥺
But after some time searching and a little rubber ducking i realised that the HttpContext (and therefore the HttpResponse and its .Cookies) where accessible trough the incoming HttpRequest in the HttpTrigger. So when you know, pretty easy. Se below example.
After that i ran into some troubles with CORS, SameSite and other security related stuff, because my blog is a static website calling a Azure Function on another domain (but that is another post 🤔).
👇 Try the feature below 👇
Your feedback is very valuable for me. Reach out to me at Twitter @jacobmohl