Add a local machine as an Azure Function Worker

231 Views Asked by At

I have an azure function that is compute intensive. While I like the ability that azure functions has to scale dynamically using Azure cloud resources, I'd also like to be able to "Bring my own compute". That is, I'd like to be able to register a set of local servers as workers for my Azure Function and have them process jobs as they come along.

I can achieve this already by running a specific version of my function locally and have it connected to the correct storage queue. However, when I deploy a new version of the function to azure, I'd like it for my the deployments on my local servers to be updated as well. Is there a way to do this? Or do I need to write my own script that will monitor for new versions of the function to be published and then download and run them?

1

There are 1 best solutions below

0
Jahnavi On

After a workaround on your requirement, I found few approaches which are detailed below.

Approach-1:

Using Devops pipelines:

Using Azure Pipelines, you can create a pipeline with Azure DevOps, GitHub Actions that targets Azure Functions and continuously changes your function app code. This pipeline can be set up to build and release any code changes made in your repository.

Note: And if you are using storage queue configuration for local servers, make sure that your local servers are connected to the storage queue properly.

Approach-2:

External package URL's:

External package URLs can also be used to refer to a remote package (.zip) file containing your function app. The file is downloaded from the URL specified, and the app is launched in Run From Package mode.

When you update a function app's package file, you must manually sync triggers to notify Azure that the app has changed. When you update the contents of the package file rather than the URL, you must manually restart your function app.

Approach-3:

As @Thomas suggested, you can also create a container app and host it for the function app deployment as detailed in MSDoc.

When building a new function app in a Container Apps environment, the AzCLI command specifies the minimum and maximum replica count. Modify/Set count for max and min replicas for your existed function app by using below command.

az functionapp config container set --name <appname> --resource-group <resourcegroup> --max-replicas 15 --min-replicas 1

enter image description here

Approach-4:

Custom Deployment Script:

You can also create a custom script which should contains script for obtaining the most recent deployment package from the artifact storage location, install and execute the new code on your local server.