App Service Oracle Client

Vazquez Zabdiel 0 Reputation points
2023-10-20T16:37:46.57+00:00

Hello community, it is possible to install the Oracle client in the application service in Linux web application (APP service PHP 8.2), the question is if this configuration is possible or is it necessary to change to VM

Greetings

Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
1,175 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Grmacjon-MSFT 19,151 Reputation points Moderator
    2023-10-20T23:33:52.8033333+00:00

    Hi @Vazquez Zabdiel thanks for the question.

    Yes, it is possible to install the Oracle client in an Azure Linux Web App running PHP 8.2. However, there are some limitations to consider.

    Azure Linux Web Apps run in a sandboxed environment, which means that you cannot install software directly on the host operating system. Instead, you can install software in the application's file system or in a custom container.

    To install the Oracle client in your Azure Linux Web App, you can follow these general steps:

    1. Create a custom container that includes the Oracle client. You can use a Dockerfile to create the container. Here's an example Dockerfile:
    FROM php:8.2-apache
    
    # Install Oracle client dependencies
    RUN apt-get update && \
        apt-get install -y libaio1 && \
        rm -rf /var/lib/apt/lists/*
    
    # Copy Oracle client files to container
    COPY instantclient_19_8 /usr/local/instantclient
    
    # Set environment variables for Oracle client
    ENV LD_LIBRARY_PATH /usr/local/instantclient
    ENV ORACLE_HOME /usr/local/instantclient
    
    # Install PHP OCI8 extension
    RUN docker-php-ext-configure oci8 --with-oci8=instantclient,/usr/local/instantclient && \
        docker-php-ext-install oci8
    
    1. This Dockerfile installs the Oracle client dependencies, copies the Oracle client files to the container, sets environment variables for the Oracle client, and installs the PHP OCI8 extension.
    2. Build the custom container and push it to a container registry. You can use Azure Container Registry or another container registry of your choice.
    3. Configure your Azure Linux Web App to use the custom container. You can do this by setting the DOCKER_CUSTOM_IMAGE_NAME application setting to the name of the custom container in the container registry.
    4. For example, if you pushed the custom container to Azure Container Registry with the name myregistry.azurecr.io/mycontainer:latest, you would set the DOCKER_CUSTOM_IMAGE_NAME application setting to myregistry.azurecr.io/mycontainer:latest.
    5. You can set the application setting in the Azure portal or using the Azure CLI: `az webapp config appsettings set --resource-group <resource-group-name> --name <web-app-name> --settings DOCKER_CUSTOM_IMAGE_NAME=myregistry.azurecr.io/mycontainer:latest

    `

    Note that you may also need to set other environment variables for the Oracle client, such as TNS_ADMIN and NLS_LANG, depending on your specific configuration.

    Lastly, there is different approach you can try which is shared here in this related Stack Overflow thread

    Hope that helps.

    -Grace

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.