Creating your first Precompiled Azure Function

Since a couple of weeks it is possible to create Precompiled Azure Functions.  This enables the use of .NET assemblies containing the function implementation, and bypassing the dynamic compilation process.

Precompiled Function

In order to use precompiled functions, you need to create a .Net assembly and adjust the function.json file. First of create a class library within Visual Studio  and add the following class:

using Microsoft.Azure.WebJobs.Host;

namespace MsftPlayground.Function {
    public class LoggingFunction
        public static void Run(string input, TraceWriter log) {
            log.Info($"Manually triggered PRECOMPILED function: {input}");

For this to work and compile the “Microsoft.Azure.WebJobs” NuGet packages needs to be added to your project.

Once the function method it self is able to compile we can create the “function.json” file. Important for this file is:

  • scriptFile: The file that contains the function.
  • entryPoint: The fully qualified method name.

All of these options together create the following “function.json” file for a manually triggered function.

  "scriptFile": "MsftPlayground.Function.dll",
  "entryPoint": "MsftPlayground.Function.LoggingFunction.Run",
  "disabled": false,
  "bindings": [
      "type": "manualTrigger",
      "direction": "in",
      "name": "input"

Azure Function

No that we have the correct files in place we need to get this up and running in Azure.

  1. Open the Azure Portal (
  2. Navigate to the resource group where in you want to create the Function or create a new one.
  3. In the resource group click “Add” to create a “Function App”.

Create Azure Function App

  1. In the created Function App create a new function. In this example a C# Manually triggered function will be created.

Add Manual Trigger Function

  1. In the develop section of the function click on “View files”.

Azure Function Code

  1. In the file browser delete the “run.csx” file and adjust the “function.json” file as mentioned above.
  2. Now use the upload button to upload the compiled file.
  3. Click the “Run” button so see if your compiled function works.

Azure Function Function Json

The functionality looks very promising and make sure you bypass the dynamic compilation process. But there are a few things to keep in mind when the Azure Function:

  • When you make manual adjustments within the portal the function.json file will be refreshed (both scriptFile and entryPoint properties will be removed).
  • Compiled files will only be loaded the first time you run the function. When you make changes to the compiled file you will need to restart the function app before changes will be applied.

Restarting the complete Azure Function App can be done via:

  1. Open the Function App.
  2. Click on Function App settings.
  3. In the settings window click “Go to App Service Settings”
  4. In the overview blade click on “Restart”.

All source files are available on GitHub:

Related Posts

VSTS Extension for Azure Role Based Access Control Today I published an extension for Visual Studio Team Services (VSTS) that gives you the ability to add and remove role based access assignments in Az...
Listing Azure Services within a CSV file In some situations you will look into a current Azure Environment and the setup/governance of it and need to migrate or move resources around. The ...
Azure Event Grid with Custom Events As of yesterday (16-8-2017) the public preview of Azure Event Grid is live. Azure Event Grid is a fully managed event routing service. Azure Event Gri...
Removing the Classis Hybrid Connections from Azure (Azure BizTalk Service) As you know the classic hybrid connections that are build upon Azure BizTalk Services are deprecated. These connection will have to be replaced by the...
Restricting access to your Azure Web Application As you may know almost everything that is deployed to Azure is publicly available. As with Azure SQL Database you do not have a firewall available for...
Configure access to a private network for a Azure App Services On-Premise connections for Azure App Services can be created by using Hybrid Connections. Hybrid connections do not need any development or re-configu...


Leave a Reply

Your email address will not be published. Required fields are marked *