<p>I m rewriting Azure Compute Services Web Role and Worker in .NET Core to work with Azure AKS.
The Web Role was pretty straight forward to migrate to ASP.NET Core in AKS, but for the worker role I m a bit lost on what to do.</p>

<p>The worker role was just listening to Azure Service Bus queue for photos to encode. I have seen that I can run azure functions runtime on AKS and setup a Bus Queue trigger, but it seems a bit overkill to setup all the azure functions runtime for this unique tasks.</p>

<p>Can someone point me in the right direction on how I can achieve that using .NET Core, Service Bus Queue and if possible setup automatic scaling according to the number of queue messages or the CPU usage?  </p>

<p>For a simple example of a .NET Core message receiver, please refer to Microsoft's <a href="https://learn.microsoft.com/en-us/azure/service-bus-messaging/service-bus-dotnet-get-started-with-queues#receive-messages-from-the-queue" rel="nofollow noreferrer">Get started with Service Bus queues</a>.</p>

<p>To get your .NET Core app running in the cluster, you'll need to build it into a Docker container. You should be using Docker multi-stage builds to create your run-time container. Microsoft has a good reference: <a href="https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/docker/building-net-docker-images?view=aspnetcore-3.1#the-dockerfile-1" rel="nofollow noreferrer">Docker images for ASP.NET Core</a>.</p>

<p>KEDA and Horizonal Pod Autoscaler will both increase or decrease pod count based on metrics. K8S HPA would be a good fit if you wanted to scale based on CPU utilization. KEDA has a <a href="https://keda.sh/docs/1.4/scalers/azure-service-bus/" rel="nofollow noreferrer">scaler for Azure Service Bus Queues</a>.</p>
