This document explains how to deploy a GeneXus application as Azure Functions.
Summary
Install the requirements in the machine where you will run the deployment —you only need Azure CLI.
In the Azure portal, follow the steps below:
- Create the resources in Azure. See HowTo: Create an Azure function app.
- To authenticate, configure a Service Principal.
In GeneXus, follow the steps below:
- Create a Deployment Unit object and select the objects to deploy.
- Use the Application Deployment tool to select the target "Microsoft Azure Functions".
To deploy the Backend services of an app, select the target "Microsoft Azure serverless (backend services)". In this case, the Functions are deployed as HTTP-triggered functions.
- Configure the properties in the property grid.
- Click on the deployment button to deploy to Azure.
Azure functions have Trigger Types (Trigger type property in the Deployment Unit).

Depending on the trigger type of the functions, you have to consider different aspects when deploying.
To consider those aspects, you may group the functions that have a trigger other than HTTP and those that have an HTTP trigger.
For all functions except those that have an HTTP trigger, consider the following when deploying the application.
This is an example of a timer-triggered function:

See Azure HTTP-triggered functions
The solution is configured to internally invoke the GeneXus objects that represent Azure Functions using an environment variable of the form:
GX_AZURE_<FUNCTION_NAME>_CLASS, where FUNCTION_NAME is the name of the function.
This environment variable is used to know the mapping between the function and the GeneXus object associated with it.
The value always contains the namespace or package name of the KB, followed by the name of the modularized GeneXus object.
Note that the GeneXus object is prefixed by "a".
Sample:

If the environment variable is not defined, a file named gxazmappings.json that contains the same information is searched for.
File sample:
[
{
"FunctionName": "QueueTriggerJava",
"GXEntrypoint": "com.testazurefunctionsjava.test.testqueue"
},
{
"FunctionName": "testfunction",
"GXEntrypoint": "com.testazurefunctionsjava.test.queuetriggeredfunction"
}
]
In the case of .NET, this file is generated in addition to the environment variable. In JAVA, only the environment variable is defined.
If neither the environment variable nor the file is found at runtime, this error occurs:
FunctionConfigurationException: File gxazmappings.json not found. The file is attempted to be read when there is no GX_AZURE_<FUNCTIONNAME>_CLASS environment variable pointing to the GeneXus class associated with the function.
First, take into account that when the function is published on an existing function app, the function is updated.
There is great flexibility for deployment in the sense that if you need to change any setting, you do not need to re-deploy.
Depending on the function, it is preferable to be able to change some settings in the cloud. Those settings are configured at deployment time, and you can set the deployment engine to create an application setting in the cloud with the name and value you specify.
In other cases, the deployment engine does not define the settings, and it's your responsibility to do it (as part of the infrastructure setup of the function).
For example, for timer functions, you can specify a cron time, or an application setting (to be created in the cloud with the name and value that you wish).

For the last option, the advantage is that all changes can be made in the cloud (you don't need to deploy again for those changes).

The same happens with other function types like Queue or Service Bus, where the connection data is defined as an app setting.
For those cases where there is no property to specify the App settings and its value, you can also have the flexibility of using App Settings.
For example, in the case of Service Bus or Queue trigger, instead of configuring a fixed value for the queue name, etc., you can configure the Application Setting name between "%" which can then be defined in Azure with a value (you have to define the App Setting in Azure).
This allows you to deploy without leaving fixed values. That is, there is no need to re-deploy just because the function is going to use another Queue or Service Bus, etc.

The behavior of all functions within the function app 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 in the host.json file.
Important: You have to manage manage this file.
- In the case of Java, it can be copied to the <GENEXUS INSTALLATION>\DeploymentTargets\Azure Functions\Templates\Java folder (and replace the existing one).
- In the case of .NET, you can replace the file existing at <GENEXUS INSTALLATION>\ DeploymentTargets\AzureFunctions\AzFunctionFiles\src.
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 (see Deployment of additional files and directories).
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
}
}
}
}
If the function app uses Image, Audio, Video, or BlobFile data types, you have to configure the Storage Provider property because all multimedia must be served from an external URL, such as Microsoft Azure.
For the same reason, it's not supported to use the file system to serve content; that is, to have read/write access to files (such as Blob data type, Excel, or PDF reports).
For solutions using GAM, see HowTo: Use GAM in Azure serverless architecture.