How to deploy to Azure Functions

Official Content
This documentation is valid for:

Azure functions are based on a serverless execution model (it is the equivalent of Amazon Lambda) and extend the concept of a PaaS (which abstracts from the infrastructure details and facilitates auto-scaling). In addition, serverless has a pay-per-execution system.

In summary, the benefits of Serverless are as follows:

  • Automatic scaling
  • Reduction of time to market
  • Agile deployment
  • Pay-per-use

(Gartner) "Serverless architectures enable developers to focus on what they should be doing –writing code and optimizing application design– making way for business agility and digital experimentation."

Scenarios

In general, we want to solve scenarios where we want data processing to react to "events;" also, we want to pay only for the resources that are consumed. Data processing can be triggered as a cron, or react to a trigger. There are different types of triggers (e.g.:Timer, Queue, Blob Storage, etc).
For more information, see Azure Functions triggers and binding concepts.

Timer Trigger Functions

They are timed functions. One possible scenario is updating the merchandise stock, or updating the redundancies of a DB.
They are not suitable for long-running batch procedures.

How to deploy to Azure Functions

Installing requirements

  • Install the requirements in the machine where you will run the deployment: you just need Azure CLI (version 2.12.1 or higher).

Setting up the cloud

Deploying the application

  • Create a Deployment Unit object with only one main procedure. Procedures have nothing particular in their logic, except considering the parameters they receive according to the function trigger.
    Note: In the case of Timer-triggered functions, the procedure receives no parameters.
  • Use the Application Deployment tool to select the target of the Azure functions.
  • Configure the properties in the property grid.

image_20201210211228_1_png

When the function is published on an existing function app, the function is updated.

Global configuration of functions

The behavior of all functions within the App function can be configured globally. This is done in the host.json file. For example, in that file, you can configure the trace level for the app, Health Monitor, etc.
Azure functions have a default timeout, which can also be changed at the host.json file.

The GeneXus user has to manage this file. The Application Deployment Tool uploads one with the basic settings, but if you want to use another you can edit it and add it to the deployment unit.

Sample host.json file to generate trace information:

{
    "version": "2.0",
    "logging": {
        "fileLoggingMode": "always",
        "logLevel": {
            "default": "Trace",
            "Host.Results": "Trace",
            "Function": "Trace",
            "Host.Aggregator": "Trace"
        },
        "applicationInsights": {
            "samplingExcludedTypes": "Request",
            "samplingSettings": {
                "isEnabled": true
            }
        }
    }
}

Considerations

When publishing in the Linux Operating System, if the Function app is down, it throws the following error:

Error publishing to Azure Functions: ServiceError: Operation returned an invalid status code 'Bad Request'
Failed: Deploy Application 

Availability

In GeneXus Beta Channel.

Limitations

  • For now, it is possible to publish only one function at a time.
  • Only Timer-Triggered functions are supported.

Additional Information

HowTo: Monitor Azure functions