Tag: azure functions
-
Mocking FunctionContext GetLogger using Durable Functions Isolated Worker
Although you can inject your ILogger<T> into the constructor of your function, sometimes you may want to use the FunctionContext from your trigger method. Mocking this for testing can be a bit tricky. Consider the following function: We want to write tests for our class. For this to be testable, we’ll need to somehow mock…
-
Cosmos DB Change Feed Processed by Azure Functions – Application Insights Telemetry
While working with a Cosmos DB Change Feed processor running as an Azure Function, I noticed that ‘requests’ are logged as Application Insights telemetry, but show up with no URL, and a response Code of 0. I was able to reproduce this using a lean example, generated from the func new generators. (Code available here:…
-
Using Mediatr with Azure Functions
I’ve used Mediatr for some time, to reduce controller action bloat, and have spoken about it a few times, on how I use it to avoid the classic ‘xService’ pattern: Controller Action -> ‘Service’ -> Repo Lately, I’ve been doing a lot of work with Azure Functions, and would like to be able to use…
-
Reliably Processing Azure Service Bus Topics with Azure Functions
At ASOS, we’re currently migrating some of our message and event processing applications from Worker Roles (within classic Azure Cloud Services) to Azure Functions. A significant benefit of using Azure Functions to process our messages is the billing model. As an example, with our current approach, we use a Worker Role to listen to subscriptions…
-
Disable gzip responses in Azure Functions
By default, responses from Http Triggered Azure Functions are gzipped: Not all clients are able to handle this (although they should be) Turning it off isn’t particularly trivial. A change needs to be made to applicationhost.config – which is located in LocalSiteRoot/Config However, this file is readonly, so the change needs to be made via…
-
Azure function not receiving json messages using Topic Service Bus Trigger
While developing an Azure Function application, using this tutorial, I encountered a problem. Ultimately, using `func new` generated my function (the run.csx file) which looked like this: public static void Run(string mySbMsg, TraceWriter log) { log.Info($”C# ServiceBus topic trigger function processed message: {mySbMsg}”); } Side note: the `mySbMsg` is important – it’s defined in the…