<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Terence Sheppard on Medium]]></title>
        <description><![CDATA[Stories by Terence Sheppard on Medium]]></description>
        <link>https://medium.com/@tsheppard01?source=rss-759796212ed0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*S-T50z4UuHYSsVREqw_loQ.jpeg</url>
            <title>Stories by Terence Sheppard on Medium</title>
            <link>https://medium.com/@tsheppard01?source=rss-759796212ed0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 06:51:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tsheppard01/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Should I Centralise Interactions with External Services?]]></title>
            <link>https://tsheppard01.medium.com/should-i-centralise-interactions-with-external-services-7b28e1377fa3?source=rss-759796212ed0------2</link>
            <guid isPermaLink="false">https://medium.com/p/7b28e1377fa3</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-architecture]]></category>
            <dc:creator><![CDATA[Terence Sheppard]]></dc:creator>
            <pubDate>Wed, 12 Feb 2025 23:54:15 GMT</pubDate>
            <atom:updated>2025-02-14T15:30:56.471Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/424/1*9uHSNRp0JI6ALuy2W0Nj9g.png" /></figure><p>On a recent project, as part of our application workflow we needed to call out to an external third party API to retrieve some data, but we found ourselves needing to call out to this external API from several different components within our system. This is a fairly common scenario, whether it be retrieving data from an external API, using a search API or interacting with an email service. So how should we handle this? Should we centralise interaction with the external service into a single component within our system? Are there advantages to centralising? Are there any reasons we should avoid doing this?</p><p>The answer is, as always, it depends. There are definite advantages to centralising interactions to a single component but there are also some caveats that you should consider.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8jui82KK71LD0WcDf01Pug.png" /><figcaption>Example architecture: moving interactions with an external service from multiple front-end applications to a centralised location in the application API layer</figcaption></figure><h3>Advantages</h3><p><strong>DRY (Don’t Repeat Yourself)</strong><br>A widely accepted software engineering concept — if you have repeated code you should consider refactoring it into shared common parts or into a single shared component. Interactions with an external service are a good example of this as there are usually specific ways to authenticate and communicate with the service, process responses into a domain objects, handle errors, etc.</p><p><strong>Maintainability and Extensibility</strong><br>If we need to update how we interact with the external service, e.g. security updates or bug-fixes, or if we want to replace the service completely with a different service, having only one place to update everything make the change easier and quicker and limits the blast radius of the change.</p><p><strong>Simplifying Front-end Applications</strong><br>In many cases we want our front-end applications to be as simple as possible. They only have responsibility for data capture/display and user experience, handing all other responsibility to a back-end. Removing interactions with external services will allow front-end applications to be more focused on their single responsibility.</p><p><strong>Scalability and Performance</strong><br>Depending on the architecture, the centralised component can potentially be scaled independently of the rest of the system. We can also implement any strategies to improve performance in a single place.</p><p><strong>Logging and Monitoring</strong><br>You will need to monitor interactions with any external services and create alerts for certain scenarios, e.g. external service is misbehaving. Having all logs in a single location and not having to collate logs or metrics from different locations simplifies this.</p><p><strong>Debugging</strong><br>Debugging problems will be easier and more streamlined, with a single point of failure to focus investigations.</p><p><strong>Error Handling</strong><br>Custom error handling, which could potentially be quite complex, only needs to be implemented once. With a centralised service we could also implement some specific error strategies in a single place, for example, if we want to implement a circuit breaker.</p><p><strong>Auditing and Security</strong><br>If we want to audit or restrict access to the external service, having a single location makes configuration and monitoring of this simpler, reducing the chances of unauthorised access.</p><p><strong>Network Security</strong><br>Fewer egress points in the network reduces chances of unauthorised data leaving our network and makes network security policies simpler to set-up and manage.</p><p><strong>Application Configuration<br></strong>Any secrets associated with the external service only need to be made available to the component interacting with the service. Not only does this reduce initial effort and ongoing maintenance, it also reduces chances of secrets being compromised — although generally less of a problem with modern applications using a central secret store.</p><h3>Caveats</h3><p><strong>Initial Effort</strong><br>There is effort, work and time associated with creating the centralised component. Perhaps we don’t already have an appropriate API layer/back-end/micro-service, in which case we would have to set this up, with all the associated infrastructure, monitoring, alerting etc</p><p><strong>Ongoing Maintenance</strong><br>Not only is there initial effort but there is also ongoing maintenance to consider. This centralised service will potentially exist for the lifetime of the application and inevitable things will go wrong and require fixing which, again, requires time and effort.</p><p><strong>Noisy Neighbours</strong><br>When multiple clients share the same resource there is the potential for one client (the noisy neighbour) to effect the performance of other clients. For example if the external API has throttling limits, one client making a large number of requests could potentially hit this limit, leaving other clients unable to make requests. There are strategies to counter this, such as limiting client requests to a safe level or having each client isolated from others but these could be costly and complex to implement, even requiring a rethink of your projects architecture.</p><p><strong>How Complex is the Interactions with the External Service</strong><br>Some of the advantages of centralising assume that interacting with the external service is fairly complex, but this is not always the case. If the interaction is simple, the effort involved in centralising it can greatly out-weigh the overhead of duplication.</p><p><strong>Single Point of Failure</strong><br>By coupling multiple components in your system to the centralised service a single point of failure has been introduced into the system. If the central component goes down then multiple components will be effected. This may not be an increased risk if, for example, you are adding an endpoint in an existing API or are using a queuing system, but if this is a new separate component it would be worth assessing this risk and considering mitigations.</p><p><strong>Alternative Approaches</strong><br>Ask are there any alternative approaches that could be quicker, less risky less effort. Maybe you don’t have an API layer or a back-end but do have shared code repository, would a shared npm package be a good fit. Maybe you have a multi-project git repo, could you have a shared library in your git repo?</p><h3>Conclusion</h3><p>In the end, the solution to your problem will depend entirely on your situation, architecture, business requirements and delivery timelines, but you should probably take these consideration into account. As you can see most of these considerations boil down to DRY, but it’s important to remember this is a guideline rather than a hard and fast rule. As software developers our aim should be to get working software into the hands of users as quickly and safely as possible and trade-offs are inherent in that. It’s our accumulated experience that tells us which trade-offs are worth it and which are not.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7b28e1377fa3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Performance Optimisation of Queue Triggered Azure Function Workflows]]></title>
            <link>https://tsheppard01.medium.com/performance-optimisation-of-queue-triggered-azure-function-workflows-4d38a3a3e97b?source=rss-759796212ed0------2</link>
            <guid isPermaLink="false">https://medium.com/p/4d38a3a3e97b</guid>
            <category><![CDATA[azure-functions]]></category>
            <category><![CDATA[messaging]]></category>
            <category><![CDATA[azure-cosmos-db]]></category>
            <category><![CDATA[performance-optimization]]></category>
            <dc:creator><![CDATA[Terence Sheppard]]></dc:creator>
            <pubDate>Mon, 06 Feb 2023 17:28:10 GMT</pubDate>
            <atom:updated>2023-02-06T17:28:10.807Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*jbBfPyMs0-n5ZZiA8rBX2w.png" /></figure><p>Whats makes a performant system? To different people it will be different things, like meeting a throughput target, hitting a certain average response time or having a highly available service. Whatever the case, performance optimisation is usually all about finding the bottlenecks within your application that prevent you from meeting these targets. Here I will look at performance optimisation of workflows that use queue-triggered Azure Functions and some of the commonly used Azure services.</p><h3>An Example Notification and Messaging System</h3><p>Messaging systems come in many different guises, from peer to peer chat apps to automated application emails and everything inbetween. However they usually share the same backbone architecture — a service to accept incoming message requests, another service to actually send the messages and a third service to give feedback to the original requester eg delivery receipts.</p><p>Imagine a scenario where an organisation wants to send messages to individual users of their application. Because it’s a mobile app they also want to send a notification to a users device to notify them of the message.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/851/1*ksJv8xowyjXBUO1HFcPz2g.png" /><figcaption>Example Message Processing Service</figcaption></figure><p>For the backbone of this system lets use a combination of Azure Storage Queues and queue triggered Azure Functions. CosmosDB is used to store a users messages and Azure Notification Hub is used to send notifications to a users device. For brevity this system won’t handle delivery or read receipts (but Eventhubs are a good choice for handling those).</p><p>Let’s use this system to understand some generic ways to investigate and improve the performance of any queue-triggered azure function workflow.</p><h3>Performance Testing</h3><p>Performance optimisation is all about finding bottlenecks within systems. If you don’t have an easy, repeatable way to run performance tests and the tools to analyse the results you won’t get far — so this should be the first thing you do. Frameworks like Gatling allow you to write journeys that can mimick a users journey through your application and can execute that journey concurrently for a specified number of users. Application Insights can give a lot of good information for analysis and with an Azure Workbook you can create a dashboard to give an overview of performance.</p><p>Things to look out for that might indicate a bottleneck and help pinpoint it are:</p><ul><li>Lower than expected throughput</li><li>A plateau in throughput despite adding extra input load</li><li>High azure function execution times</li><li>High latency for requests to CosmosDB, Eventhub, Storage Queue etc</li><li>High RU consumption in CosmosDB</li><li>500s or 429 response codes from Azure services</li><li>Enabling or disabling a part of the system changes throughput eg an API call to another part of the system is mocked and throughput increases</li></ul><h3>Performance Tuning</h3><p>There are some fairly simple things that can greatly effect the performance throughput of our example system.</p><h4>C# and Azure SDK Clients</h4><p>I’ve encountered a few issues while using C# Azure SDK clients that only become apparent as load is increased. Here are a few things to rememeber when writing code:</p><ul><li>Ensure any clients are reused across function invocations as there is usually some cost associated with their creation</li><li>For HttpClients use the HttpClientFactory as it will manage connection pooling and the lifecyle of the clients for you</li><li>For other clients, make sure they are created as static variables or use dependency injection to register them as singletons. If using the provider pattern the provider should be regstered as a singleton</li><li>The Azure Storage Queue client does not have any kind of connection pooling, with each request creating a new connection. A large number of concurrent requests can lead to an exhuastion of available outbound connections in the function app. Make sure that the number of parallel requests is managed in code by the application (hint: use semaphores)</li><li>The Azure CosmosDB client offers 2 modes of connection, Direct mode, which connects directly to the backend CosmosDB VMs, and Gateway mode, which connects via an intermediate node. While direct mode offers lower latency by reducing network hops, I’ve seen high timeout rates when using it in some scenarios. Gateway mode offers more stability when the number of outbound socket connections is limited</li><li>The Azure EventHub client allows batching of events which can potentially improve throughput when the request rate is high. There is an <em>EventHubBufferedProducerClient</em> that handles this batching internally. But think of the impact of failed requests eg if an azure function is killed before a batch is sent events will be lost</li></ul><h4>Function App Sizing and Scaling</h4><p>There are a few different Function App Service plans available and the one you choose will depend on your needs. There are a few versions with different vCPU and memory limits. Look at CPU and memory usage when your application is under load to help decide which one suits best. Here are a few other things to consider:</p><ul><li>Permium App Service plans offer always-on functionality, important if cold starts are to be avoided. They also offer VNET integration</li><li>Use service endpoints if possible, this will keep network traffic within the Azure backbone network thereby reducing likelihood of network latency problems</li><li>Enable auto-scaling. Premium Plan function apps can scale out from 1 instance to 30 instances to meet demand. A good strategy for spikey traffic is to scale out quickly but scale in slowly</li><li>Ensure performance from cold start is adequate. If you need to be able to handle spikes in traffic as quickly as possible then the auto-scaling scale out might need to be aggressive or you may need to provision a higher default number of function app instances</li><li>For queue triggered functions, increase the maxBatchSize config parameter — this will allow you to process more queue items in parallel</li></ul><h4>CosmosDB Paritioning</h4><p>In our example system we are writing a users messages in to a CosmosDB collection, but we could also conceivable have other data we need to read or write eg user metadata, event audit logs, etc. With CosmosDB it is tempting to just increase the provisioned RUs to increase performance, but an unoptimised DB can quickly become slow and expensive.</p><ul><li>For reads, ensure the field you are querying by is the partition key of the collection, otherwise a full table scan is performed with queries across multiple backend VMs. This consumes more RUs and takes longer. If you absolutley can’t change the parititon key, then make sure to use indexed fields</li><li>For writes, ensure the partition key space of your write operation is large enough to prevent “hot partitions”. Hot partitions occur when a large amount of data is directed to a single partition on a single backend VM. No matter how many RUs are provisioned, this will limit throughput</li><li>If there are mulitple processes that need to query the same data in different ways, don’t be afraid to hold multiple copies of that data with different partition keys or different shape — storage is cheap in CosmosDB</li></ul><h3>Architecture Enhancements For Performance Optimisation</h3><p>For some Azure services we will, at some point, hit up against a hard throughput limit. To push things further we can start to think about parallising some of those services.</p><h4>Storage Queues and Storage Accounts</h4><p>Individual Storage Queues have a throughput limit of 2,000 transactions per second, with each PUT or GET or DELETE on a queue item counting as a transaction. This means that in theory the maximum throughput of our example system is limited by the storage queues to around 1,000 messages per second. If we update our design to use multiple storage queues in parallel then the overall limit will be increased. We can do this by replacing the single workflow in our initial desgin with multiple workflows running in parallel. Each workflow uses a different set of storage queues so the overall limit is <em>num workflows x 1,000</em>. The incoming requests can be directed to one of the processing workflows based on some kind of custom partitioning.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/972/1*p05iC5rzN82ZuKCzD2wErQ.png" /><figcaption>Multiple parallel workflows</figcaption></figure><p>There is also a 20,000 transaction per second limit on Storage Accounts. In our case, 10 workflows running at full speed could theoretically hit this limit. By using multiple storage accounts and spreading the storage queues between those accounts we can increase this limit.</p><h4>Function App Service Plan Separation of Concerns</h4><p>In the initial design all the functions lived inside the same Function App service plan, competing with each other for resources. If this becomes a problem, rather than simply scaling up the service plan think about separating out the functions more logically into separate Function App service plans. This would create more headroom for each set of functions, potentially increasing performance and allow each set of functions to scale independently.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1rVv1V42MbzifAxJEnGPBg.png" /><figcaption>Multiple function app service plans for each step in the processing workflow</figcaption></figure><p>With a Permium Function App service plan we can scale to 30 function app instances. If this isn’t enough than we could think about scaling out to multiple Function App service plans. Keep in mind that this would bring some management overhead, eg each new service plan would require a new set of storage queues, how are requests directed correctly or evenly across theses storage queues?</p><h3>Conculsion</h3><p>I’ve given a rundown of some common problems encountered in queue triggered Azure Functions using a messaging service as an example. I’ve shown how to first, get up to 1,000 messages per second through the system and then went on to suggest how we might break that barrier and push on to 10,000+ messages per second.</p><p>The exact optimisations needed for an individual system all depends on the expected load and SLAs for the production system. But if you take nothing else from this it should be that performance testing is essential not just for highly scalable systems but for any system with NFRs and SLAs around processing times and throughput. You may think your system is performant enough but you need to prove it.</p><p>Happy optimising!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4d38a3a3e97b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Azure Function Development on MacOS with Docker]]></title>
            <link>https://tsheppard01.medium.com/azure-function-development-on-macos-with-docker-121d0b1ff07e?source=rss-759796212ed0------2</link>
            <guid isPermaLink="false">https://medium.com/p/121d0b1ff07e</guid>
            <category><![CDATA[macos]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[azure-functions]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Terence Sheppard]]></dc:creator>
            <pubDate>Tue, 23 Feb 2021 17:00:08 GMT</pubDate>
            <atom:updated>2021-02-24T10:58:25.561Z</atom:updated>
            <content:encoded><![CDATA[<h4>Creating a queue triggered Azure Function and running locally using Docker</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_67Y8U5GbhpsJESnqGQKGw.png" /></figure><p>As a developer, one question that always comes up when using any cloud provider as your platform of choice is, “How do I integrate cloud services with my development environment?”</p><p>You have a two main options, provide a full cloud environment for each developer (can be expensive and tricky to set up correctly), or run everything locally on your dev machine. There are, of course, hybrid solutions but when starting a new project the quickest and easiest solution is often to run locally.</p><p>In this post I will show how to create a queue triggered Azure Function and get it running in a local development environment using Docker on MacOS. The source code for all of this is available on my <a href="https://github.com/tsheppard01/QueueTriggeredAzureFunction">github</a>.</p><h3>A Problem to Solve</h3><p>First lets consider an example of where we might want to use a queue triggered Azure Function — Asynchronous messaging.</p><p>Asynchronous messaging is a pattern used in many architectures to decouple services. The idea is that rather than communicating directly, services communicate via messages that are typically placed on a queue. The services then no longer rely on each other, so if one becomes unavailable the other can carry on unaffected.</p><p>By combining the asynchronous messaging pattern with serverless, where the push of a message to a queue triggers the invocation of function, you can stitch together these loosely coupled services with minimal configuration.</p><p>On a recent project we used asynchronous messaging to decouple a user-facing front-end web app from a data processing back-end.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*4W5qE4nFpTyD2pXYqSn2aQ.png" /></figure><p>On the front-end web app the user enters data into an online application form. This data is then pushed as a Json message to an Azure Queue Storage queue, triggering an Azure Function. This function reads the message, performs some transformations on the data and ultimately uploads a file to an Azure Blob Storage container.</p><p>We’ll use this use case as the basis of our example in this post.</p><h3>The Devs Toolset</h3><p>Mircosoft have always provided a great suite of developer tools in Visual Studio. They also provide utilities for developers who are more at home on the command line, <a href="https://docs.microsoft.com/en-us/dotnet/core/tools/">dotnet</a> for creating and running .net projects and <a href="https://docs.microsoft.com/en-us/azure/azure-functions/functions-run-local?tabs=macos%2Ccsharp%2Cbash">func</a> for creating and running Azure Functions.</p><p>I come from a varied dev background and I am never to far away from a terminal. I prefer using command line utilities compared to GUI interfaces, so these tools are a great fit for me.</p><p>As mentioned, I’ll be using <a href="https://docs.docker.com/">Docker</a> for running everything in our local dev environment. From experience, as the number of components in your project increases it always makes sense to start using Docker, so you should just use it from the beginning.</p><p>I’ll also be using <a href="https://docs.docker.com/compose/">Docker-compose</a> for container orchestration. This will allow us to create and run all the docker containers we need with a single command.</p><h3><strong>Creating the Project</strong></h3><p>First up, we need to create the solution and project scaffolding. To do this, run these commands in your terminal of choice:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/34138f69ca6aafca4e81fffa7ef8a298/href">https://medium.com/media/34138f69ca6aafca4e81fffa7ef8a298/href</a></iframe><p>This creates the solution, the project, all associated folders and some template files. The most notable files created are the class QueueTriggeredFunction, which is the main entry point for the function and local.settings.json which contains the settings needed to run the function locally using the command line utilities (or Visual Studio).</p><p>Now that we have the project scaffolding, lets wire things together and write some code to do something with the queue message. The main entry point of the Azure Function looks like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6333850c4dfebbe3459d0c7fe63e40ac/href">https://medium.com/media/6333850c4dfebbe3459d0c7fe63e40ac/href</a></iframe><p>The parameters “SourceQueueName” and “SourceQueueConnection” in the “Run” method definition refer to parameters contained in the “Values” section of the local.settings.json file. Note that SourceQueueName is wrapped in % symbols, this is necessary to indicate it should be read from settings and not taken as a literal string. When deploying to Azure these values should be added as AppSettings in the function, and when running in a docker container they should be added as environment variables.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7ee16492469edcd4748998ed456ffb93/href">https://medium.com/media/7ee16492469edcd4748998ed456ffb93/href</a></iframe><p>I’ve create a new class, QueueTriggeredFunctionRunner, containing the main functionality of the Azure Function. It’s best practice to treat the main entry point of the function as you would a main class in a console app, use it only for dependency creation and orchestration, handing off the main logic to another class.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fe4af3e1f041f4890232e68e81432bc3/href">https://medium.com/media/fe4af3e1f041f4890232e68e81432bc3/href</a></iframe><p>The logic of our function is kept simple, it takes the message passed in from the queue and uploads the contents to an Azure Blob Storage container as a txt file.</p><p>At this point we <em>could</em> run our function on our dev machine, but there is no queue to read from and no container to upload to, so nothing will happen.</p><p>We want our dev environment to be local, so that means we’ll need to emulate Azure Storage locally somehow. Enter Azurite.</p><h3>Dockerise Things</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/324/1*cmyiHdIcmdSvyv-xmMFa8w.png" /></figure><p><a href="https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azurite">Azurite</a> is an Azure Storage emulator that can run natively as an app or run inside a docker container. We are going to run it in a docker container.</p><p>As mentioned above we’re also going to use docker-compose for container orchestration, it just makes things easier in the long run as you add more services. The docker-compose.yml file lives in the root folder of the solution and at this stage the contents look like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0f4a3ebf640b81ec41ef559e135ab8dd/href">https://medium.com/media/0f4a3ebf640b81ec41ef559e135ab8dd/href</a></iframe><p>It starts up Azurite as well as an Azure-Cli container that creates the queue and storage container required for the function to work.</p><p>To run everything all we need to do is run the commands:</p><pre>docker-compose up -d<br>cd FunctionsProj<br>func start </pre><p>To interact with Azurite you can use the <a href="https://azure.microsoft.com/en-gb/features/storage-explorer/">Azure Storage Explorer</a>. Once started it will automatically pick up the Azurite container. Now you can add messages to the queue and see them magically transported to your blob storage container!</p><h3>Dockerise All The Things</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mNz3I7DNHPN_5O7V_V8kGQ.png" /></figure><p>So far we’ve got Azurite running in a docker container and we are manually running the Azure Function. This is great during development of the function as we are able quickly make and test changes. But wouldn’t it also be great if we could have the function running in the background when we are developing other integrations — for example, an application that posts to the storage queue that’s triggering our function. Luckily, we can run the function in another docker container.</p><p>First, create a Dockerfile in the root folder of the solution. This contains instructions on how to build the function docker container.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a4350c8ccc63b1c358f085f8cedf7e1a/href">https://medium.com/media/a4350c8ccc63b1c358f085f8cedf7e1a/href</a></iframe><p>Then add this container to the docker-compose.yml, defining the settings as environment variables.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/811f0eff709ddc7df412104e724f8ba7/href">https://medium.com/media/811f0eff709ddc7df412104e724f8ba7/href</a></iframe><p>Before running docker-compose we need to build and publish the Azure Function artefacts to the folder the Dockerfile expects.</p><pre>dotnet clean<br>dotnet build FunctionsProj<br>dotnet publish FunctionsProj/FunctionsProj.csproj -c Release -o ./published/FunctionsProj</pre><p>Now just run docker-compose up -d --build . The Azure Function will start up inside a docker container and will be ready and waiting to process anything that is pushed to the queue.</p><h3>Summary</h3><p>So there you have it, I’ve shown how to create a queue triggered Azure Function and run it in a local development environment on MacOS. As you create more services you can add them into your docker-compose.yml, but there may come a point when your system is too big and sprawling to run everything locally. It’s also not always possible or sensible to run everything locally in docker so you’ve got to be pragmatic and be open to alternative approaches when setting up your dev environment.</p><p>So long and good luck!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=121d0b1ff07e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>