Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Stato74's avatar

Azure App Service Configuration Settings in Docker Laravel .ENV

Evening,

I'm trying to configure a Docker Container running as an App Service in Azure. I can get this to work but if I need to change any of the .env parameters I have to make the change, rebuild my docker image and push it back up to Azure.

The Azure documentation says I can create Configuration Settings and they will be written to the .env file but I can't get this to work.

I am wondering if this is because my application is within a docker container ? and if so do I have to a startup.sh script to run php artisan optimise so the .env values are written out ?

0 likes
3 replies
LaryAI's avatar
Level 58

To configure Azure App Service with Docker and update the .env file without rebuilding and pushing the Docker image, you can follow these steps:

  1. Create an Azure App Service Configuration Setting:

    • Go to your Azure portal and navigate to your App Service.
    • Under the "Settings" section, click on "Configuration".
    • Add a new application setting by clicking on the "+ New application setting" button.
    • Set the name and value for your configuration setting. For example, if you want to update the APP_NAME parameter in the .env file, set the name as APP_NAME and the value as the desired value.
  2. Update your Laravel application to read the configuration settings:

    • In your Laravel application, open the .env file.
    • Replace the value of the configuration parameter you want to update with the following code:
      env('APP_NAME', 'default_value')
      
      Replace APP_NAME with the name of the configuration parameter you want to update, and default_value with the default value you want to use if the configuration setting is not found.
  3. Restart your Azure App Service:

    • After updating the configuration settings, you need to restart your Azure App Service for the changes to take effect.
    • Go to your Azure portal and navigate to your App Service.
    • Under the "Overview" section, click on the "Restart" button to restart the App Service.

By following these steps, your Laravel application running in the Docker container on Azure App Service will read the configuration settings from the Azure App Service and update the .env file accordingly.

Stato74's avatar

@LaryAI I don't understand replace the value of the configuration parameter comment in your reply?

In Azure App Service Configutration settings I have a Name and a Value In the .Env I have something APP_NAME=myappname

Were do I place the env('APP_NAME', 'default_value') text ?

Stato74's avatar

@LaryAI I've resolved the problem. I carry out the steps above but don't include you .env file in your Docker build as Azure will create the .ENV during the startup process.

Please or to participate in this conversation.