azureazure-functionswavemaker

how to deploy wavemaker as serverless Azure App


Is it possible to deploy a wavemaker project as a server less Azure App? separating the front end and also turning the built in Wavemaker API's and Database CRUD into azure functions?

This is a possibility for seperating front end? but not sure about back end and APIs https://docs.wavemaker.com/learn/app-development/deployment/app-integration-with-azure-cdn/


Solution

  • Azure Functions is not recommended to deploy front end or Web apps, As Azure Functions are based on Triggers. When an event occurs the Azure Functions is Triggered, Example- If a new blob is added to storage container, Azure Function with Blob trigger will Trigger and perform an action after new blob is added, Example saving that blob to CosmosDB by using CosmosDB as an output binding. If you host your Wavemaker front End CDN in functions even after deployment, It will fail to load the files. Apart from Functions, There are other serverless solutions are available in Azure where you can deploy your Front end wavemaker. Those solutions include- Azure Kubernetes, Azure Containers which works on microservices architecture and are serverless deployments.

    I created one Java Maven Function app, But Function app is based on Trigger -

    enter image description here

    You can integrate your CDN endpoint making it publicly available as an HTTP Trigger and perform operations with Function app but cannot deploy front end code in it.

    Default Http Trigger in Java:-

    package com.function;
    
    import com.microsoft.azure.functions.ExecutionContext;
    import com.microsoft.azure.functions.HttpMethod;
    import com.microsoft.azure.functions.HttpRequestMessage;
    import com.microsoft.azure.functions.HttpResponseMessage;
    import com.microsoft.azure.functions.HttpStatus;
    import com.microsoft.azure.functions.annotation.AuthorizationLevel;
    import com.microsoft.azure.functions.annotation.FunctionName;
    import com.microsoft.azure.functions.annotation.HttpTrigger;
    
    import java.util.Optional;
    
    /**
     * Azure Functions with HTTP Trigger.
     */
    public class Function {
        /**
         * This function listens at endpoint "/api/HttpExample". Two ways to invoke it using "curl" command in bash:
         * 1. curl -d "HTTP Body" {your host}/api/HttpExample
         * 2. curl "{your host}/api/HttpExample?name=HTTP%20Query"
         */
        @FunctionName("HttpExample")
        public HttpResponseMessage run(
                @HttpTrigger(
                    name = "req",
                    methods = {HttpMethod.GET, HttpMethod.POST},
                    authLevel = AuthorizationLevel.ANONYMOUS)
                    HttpRequestMessage<Optional<String>> request,
                final ExecutionContext context) {
            context.getLogger().info("Java HTTP trigger processed a request.");
    
            // Parse query parameter
            final String query = request.getQueryParameters().get("name");
            final String name = request.getBody().orElse(query);
    
            if (name == null) {
                return request.createResponseBuilder(HttpStatus.BAD_REQUEST).body("Please pass a name on the query string or in the request body").build();
            } else {
                return request.createResponseBuilder(HttpStatus.OK).body("Hello, " + name).build();
            }
        }
    }
    

    You can use Get and Post request with your CDN endpoints in the above Function with HTTP Trigger Java & Maven.

    An alternative is to Deploy your web app by containerizing it and deploy refer here for serverless architecture and Azure App Service.

    You can refer the Blog you sent to create CDN profile and generate wavemakers artifact. Then add your CDN with Azure App service/Azure Web app by following this MS Document.

    enter image description here

    enter image description here

    To create CDN profile, I selected -Azure CDN Standard from Microsoft (classic) and then created an endpoint by selecting my Azure storage account like below:-

    enter image description here

    enter image description here

    Now, Add this CDN to your Web app whether containerized or Azure app service based:-

    Visit the Networking Section of your Web app and add the CDN like below:-

    enter image description here