[AEM Forms]{class="badge positive" title="Applies to AEM Forms)."}

Connect an Adaptive Form to Azure SQL Storage

Adaptive Forms in Adobe Experience Manager (AEM) can integrate with external databases to store or retrieve data.
This article outlines how to connect an Adaptive Form to an Azure SQL database using JDBC through AEM as a Cloud Service.

![NOTE]

This guide applies to non-sandbox AEM as a Cloud Service environments with advanced networking enabled.

Advantages

Integrating Adaptive Forms with Azure SQL offers several benefits:

  • Real-time data interaction: Enables live reading and writing of data between forms and the Azure database.
  • Scalability: Azure SQL provides scalable database performance suitable for enterprise-level applications.
  • Centralized data storage: Keeps form submissions and retrieved data securely stored in one central location.
  • Security compliance: Leverages Azure’s built-in network, firewall, and encryption options to ensure secure communication.
  • Cloud-native integration: Ideal for modern, cloud-first architectures using AEM as a Cloud Service.

Prerequisites

  • Create Azure SQL Database and ensure proxy connection is enabled.

    note note
    NOTE
    Navigate to: Azure Portal → SQL Server → Security → Networking → Connectivity to enable proxy connection.

    Create Azure Db

  • Enable Advanced networking configured using a dedicated egress IP for the created Azure database.

    note note
    NOTE
    After enabling dedicated egress IP. Go to Azure Portal → SQL Server → Security → Networking → Public Access and add the egress IP to the firewall rules.

    Egress IP

  • Set port forwarding in the cloud environment with:

    • portOrigin: Between 30000–30999

    • portDest: 1433 (default port for Azure SQL)
      For example: portOrigin: 30433 → portDest: 1433

      ![NOTE]

      You can contact Adobe Cloud Manager support to configure the port forwarding.

Steps to Connect Adaptive Forms to Azure SQL

Step1: Clone AEM as a Cloud Service Git repository

  1. Open the command line and choose a directory to store your AEM as a Cloud Service repository, such as /cloud-service-repository/.

  2. Run the below command to clone the repository:

    code language-none
    git clone https://git.cloudmanager.adobe.com/<organization-name>/<app-id>/
    

    Where to find this information?

    For step-by-step instructions on locating these details, refer to the Adobe Experience League article “Accessing Git”.

    When the command completes successfully, you see a new folder created in your local directory. This folder is named after your application.

  3. Open the repository folder in an editor.

Step2: Add Required JARs

Include the SQL driver dependency to the AEM project via the all package.:

NOTE
To include the SQL dependency in your project, refer to the SQL driver dependencies section.

Step 3: Add JDBC Configuration

  1. Navigate to the following directory within your <application folder> where the OSGi configuration for the JDBC pool should be placed:

    code language-bash
    cd ui.config/src/jcr_root/apps/<application folder>/osgiconfig/config/
    

Step 4: Create the Azure SQL Connection Configuration File

  1. Create the file:

    code language-bash
    com.day.commons.datasource.jdbcpool.JdbcPoolService~<application folder>-sql.cfg.json
    
  2. Add the below lines of code:

    code language-json
    {
    "datasource.name": "azuredbshr",
    "jdbc.driver.class": "com.microsoft.sqlserver.jdbc.SQLServerDriver",
    "jdbc.username": "<azureuser>",
    "jdbc.connection.uri": "jdbc:sqlserver://$[env:AEM_PROXY_HOST;default=proxy.tunnel]:30433;database=testdb;user=<azureuser>;password=<azurepassword>;encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30;",
    "jdbc.password": "******",
    "jdbc.validation.query": "SELECT 1"
        }
    

    ![NOTE]

    Replace jdbc.username with actual Azure username and jdbc.password with the actual secure password.

Step 5: Commit and Push the Changes

Open the terminal and run the below commands:

git add .
git commit -m "<commit message>"
git push

Step 6: Deploy the Changes via Cloud Manager Pipeline

  1. Log in to AEM Cloud Manager.
  2. Navigate to your project and run the pipeline to deploy the changes.

Step 7: Create a Form Data Model (FDM)

Once the AEM and Azure setup is complete and the code changes are deployed:

  1. Go to AEM Author instance.
  2. Navigate to Tools > Forms > Data Integrations.
  3. Create new Form Data Model.
  4. In the Data Sources tab, select the created JDBC configuration.
  5. Click Create and verify the connection.

Create Form Data Model

Step 8: Use the created FDM in an Adaptive Form

  1. Open an Adaptive Form in edit mode.
  2. Select the FDM created in the previous step as the data model.
  3. Use data bindings to connect form fields with the Azure SQL data source and configure submission action.

Best Practices

  • Use secrets management to avoid hardcoding passwords in configuration files.
  • Regularly rotate database credentials and update the config securely.
  • Monitor JDBC connectivity logs for failures and latency.
  • Follow Azure best practices for securing SQL databases and firewall configurations.
  • Avoid using high-privilege database accounts for form access.
recommendation-more-help
fbcff2a9-b6fe-4574-b04a-21e75df764ab