Azure Web Apps
Provision an Azure Web App via the Azure Portal and deploy an OntoPop API application to it.
Please note that the OntoPop backend open-source software project, which includes the event-driven data pipelines and APIs, is undergoing extensive redesign and refactoring as part of OntoPop Community 3.x in order to improve performance, security, extensibility and maintainability. As a result, the documentation on this page will be significantly updated. Please refer to the OntoPop Roadmap for further information.
Overview
Azure Web Apps (part of the Azure App Service) is an Azure cloud computing platform service that enables developers and platform engineers to deploy and scale web applications and web services developed in industry-standard languages including Java, Python, PHP, Ruby and Node.js. This page provides instructions on how to provision Azure Web Apps and then deploy the OntoPop API Spring Boot applications to them.
For further information regarding the Azure App Service, please visit https://azure.microsoft.com/en-gb/services/app-service.
It is recommended that you configure and integrate the steps described in this page into a CI/CD pipeline in order to automate the build, testing and deployment stages.
API Collections
OntoPop provides Azure API Spring Boot application deployments that wrap around each of the API collections described in the logical system architecture. These Azure Spring Boot applications are provided out-of-the-box to enable quick and easy deployment to Azure Web Apps. Assuming that you have followed the instructions detailed in Build from Source, the Azure Spring Boot applications for each of the API collections may be found in the $ONTOPOP_BASE/ontopop-apps/ontopop-apps-azure
Maven module, which itself contains the following child modules pertinent to the OntoPop APIs:
ontopop-azure-app-api-ontology-management
- Azure Spring Boot application deployment wrapper for the Management API endpoints.ontopop-azure-app-api-ontology-triplestore
- Azure Spring Boot application deployment wrapper for the Triplestore API endpoints.ontopop-azure-app-api-ontology-graph
- Azure Spring Boot application deployment wrapper for the Graph API endpoints.ontopop-azure-app-api-ontology-search
- Azure Spring Boot application deployment wrapper for the Search API endpoints.
Setup
Build from Source
In order to compile and build the OntoPop Azure API Spring Boot applications in preparation for deployment to Azure Web Apps, please follow the instructions detailed in Build from Source.
Azure CLI
If you have not already done so when deploying the OntoPop Azure Function apps as described in Azure Functions, please install the Azure CLI as follows:
The instructions below are for Ubuntu 20.04. Installation instructions for other Linux distributions and other operating systems such as Windows may be found at https://docs.microsoft.com/en-us/cli/azure.
# Remove any old installations of the Azure CLI
$ sudo apt remove azure-cli -y && sudo apt autoremove -y
# Install the Azure CLI
$ curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
# Sign into your Azure account
$ az login
Azure Web App
We shall use the Azure Portal to provision Azure Web Apps. To do so, navigate to the App Services service via the Azure Portal, select "Create" and follow the instructions below:
- Subscription and Resource Group - select the Azure subscription and resource group to use for the new Azure Web App.
- Name - enter a custom name for the Azure Web app, for example
ontopop-management-api
. - Publish - select "Code".
- Runtime Stack - select "Java 11".
- Java Web Server Stack - select "Java SE (Embedded Web Server)".
- Operating System - select "Linux".
- App Service Plan - select (or create) a new app service plan, making a note of its SKU (for example p1v2).
Once configured, select "Review + Create" to create the new Azure Web App.
Deployment
API Apps
In the following instructions we use the ontopop-azure-app-api-ontology-management
child Maven module as an example with which to demonstrate how to deploy an API Spring Boot application to an Azure Web App. However these instructions can be equally applied to deploy any and all of the Azure API Spring Boot applications listed above.
- Create a new Azure Web App configured with the Java 11 runtime via the Azure Portal as detailed in the Setup section above. We shall call this Azure Web App
ontopop-management-api
for the purposes of these instructions. - Assuming that you are integrating OntoPop with the Azure Key Vault secrets engine, to integrate the OntoPop Spring bootstrap context with Azure Key Vault we configure bootstrap.yml as follows:
spring:
application:
name: ontopop
cloud:
vault:
enabled: false
host:
port:
scheme:
authentication:
token:
kv:
enabled:
backend:
default-context:
azure:
keyvault:
enabled: true
client-id: ${AZURE_KEYVAULT_CLIENT_ID}
client-key: ${AZURE_KEYVAULT_CLIENT_SECRET}
tenant-id: ${AZURE_KEYVAULT_TENANT_ID}
uri: ${AZURE_KEYVAULT_URI}
aws:
secretsmanager:
enabled: false
name:
prefix:
defaultContext:
failFast:
region:
The Azure Key Vault client ID (i.e. the app ID of the service principal object with privileges to read secrets from the relevant Azure Key Vault instance), client secret (i.e. the password of the service principal object to privileges to read secrets from the relevant Azure Key Vault instance), tenant ID and URI properties should be set as environment variables and NOT stored as plaintext in bootstrap.yml
. Thus these environment variables should be set in our Azure Web App as application settings. To do this, navigate to the relevant Azure Web App via the Azure Portal, then select "Configuration" and "Application Settings". Select "New Application Setting" and create all the environment variables defined in bootstrap.yml
.
- When deploying Java-based apps to Azure Web Apps, Azure requires us to explicitly provide the main Java class to invoke as an environment variable called
MAIN_CLASS
. To do this, navigate to the relevant Azure Web App via the Azure Portal, then select "Configuration" and "Application Settings". Select "New Application Setting" and create a new application setting calledMAIN_CLASS
with the relevant value from the following table:
Maven Module | Main Class |
---|---|
ontopop-azure-app-api-ontology-management | ai.hyperlearning.ontopop.apps.azure.api .ontology.management.OntologyManagementApiAzureApp |
ontopop-azure-app-api-ontology-triplestore | ai.hyperlearning.ontopop.apps.azure.api .ontology.triplestore.OntologyTriplestoreApiAzureApp |
ontopop-azure-app-api-ontology-graph | ai.hyperlearning.ontopop.apps.azure.api .ontology.graph.OntologyGraphApiAzureApp |
ontopop-azure-app-api-ontology-search | ai.hyperlearning.ontopop.apps.azure.api .ontology.search.OntologySearchApiAzureApp |
- Next we need to configure another environment variable called
JAVA_OPTS
configured with the JVM memory parameters for our Azure Web App. To do this, navigate to the relevant Azure Web App via the Azure Portal, then select "Configuration" and "Application Settings". Select "New Application Setting" and create a new application setting calledJAVA_OPTS
with the value-Xms256m -Xmx1g
. - We have now set all the required Azure Web App environment variables. Press save to persist the new application settings (which will restart the Azure Web App).
- We are now ready to deploy the packaged Java Spring application artifact to the relevant Azure Web App. Assuming that you have followed the instructions detailed in the Setup section above, navigate to
$ONTOPOP_BASE/ontopop-apps/ontopop-apps-azure/ontopop-azure-app-api-ontology-management
(in our example). Next open thepom.xml
file inside this directory with your preferred text editor. In order to deploy the compiled Java Spring application artifact to the remote Azure Web App using the Azure Webapp Maven Plugin, we need to define seven (7) environment variables in our deployment environment that are used in thepom.xml
file, namely:
Environment Variable | Description | Example Value |
---|---|---|
ONTOPOP_AZURE_APP_API_ONTOLOGY_MANAGEMENT_SUBSCRIPTION_ID | The ID of the Azure subscription in which this Azure Web App is provisioned. | 12345678-1234-abcd-wxyz-987654321a |
ONTOPOP_AZURE_APP_API_ONTOLOGY_MANAGEMENT_RESOURCE_GROUP_NAME | The name of the resource group in which this Azure Web App is provisioned. | my-resource-group |
ONTOPOP_AZURE_APP_API_ONTOLOGY_MANAGEMENT_APP_NAME | The name of the Azure Web App. | ontopop-management-api |
ONTOPOP_AZURE_APP_API_ONTOLOGY_MANAGEMENT_PRICING_TIER | The SKU of the app service plan in which this Azure Web App is provisioned. | p1v2 |
ONTOPOP_AZURE_APP_API_ONTOLOGY_MANAGEMENT_REGION | The region in which this Azure Web App is provisioned. | uksouth |
ONTOPOP_AZURE_APP_API_ONTOLOGY_MANAGEMENT_APP_SERVICE_PLAN_NAME | The name of the app service plan in which this Azure Web App is provisioned. | my-asp |
ONTOPOP_AZURE_APP_API_ONTOLOGY_MANAGEMENT_APP_SERVICE_PLAN_RESOURCE_GROUP_NAME | The name of the resource group of the app service plan in which this Azure Web App is provisioned. | my-resource-group |
- Once these environment variables are set in our deployment environment, we can upload and deploy the packaged Java Spring application artifact to the relevant Azure Web App by executing the following commands via our command line:
# Login to the relevant Azure account
$ az login
# Explicitly set the name of the Azure subscription to use
$ az account set --subscription my-subscription
# Navigate to the relevant project folder
$ $ONTOPOP_BASE/ontopop-apps/ontopop-apps-azure/ontopop-azure-app-api-ontology-management
# Deploy the packaged artifact to the remote Azure Web App
$ mvn azure-webapp:deploy
The OntoPop API collection is now publicly available to serve HTTP requests at https://ontopop-management-api.azurewebsites.net
(in our example).
To configure a custom domain and secure the API, please configure Azure API Management accordingly as detailed at https://docs.microsoft.com/en-us/azure/api-management/configure-custom-domain.