Web App for Containers: sidecar containers can't see the environment variables

Carol Lai 0 Reputation points
2025-02-26T03:38:13.4466667+00:00

I have a Web App for Containers. I use the Deployment Center on Azure Portal to configure the containers. I use the advanced sidecar container support to add a main container and 2 sidecar containers. All three containers use the same image that is stored in Azure Container Registry.

When I first start this Web App, everything run well. All containers can see the environment variables defined under settings. Then if I stop and restart a few times. The main container still see the environment variables, but the sidecar containers will not be able to see the environment variables anymore.

I'm not sure how to fix this problem.

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
{count} votes

4 answers

Sort by: Most helpful
  1. Deepanshu katara 17,960 Reputation points MVP Moderator
    2025-02-26T05:02:14.8033333+00:00

    Hello Carol, Welcome to MS Q&A

    Sidecar containers in Kubernetes do not automatically inherit environment variables from the main application container, meaning they cannot directly access the environment variables set for the primary container unless explicitly defined in their own configuration; essentially, each container within a pod has its own set of environment variables, even if they share the same network namespace

    Please check this for more details

    Sidecar Containers

    Kindly let me know if have further questions

    Pls accept if it helps

    Thanks

    Deepanshu


  2. Bhargavi Naragani 7,940 Reputation points Microsoft External Staff Moderator
    2025-03-25T18:23:45.59+00:00

    Hi @Carol Lai,

    I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this! Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others ", I'll repost your solution in case you'd like to accept the answer.

    Issue: Web App for Containers: sidecar containers can't see the environment variables

    Solution:

    The newer version of the advanced sidecar container panel has a flag a shown. Once I checked that flag and all the environment variables that are defined on the Environment Variables panel can be seen in the sidecar containers.
    sidecar


    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.

    0 comments No comments

  3. Jason Thorpe 10 Reputation points Microsoft Employee
    2025-12-03T21:17:35.8133333+00:00

    [deleted].


  4. Jason Thorpe 1 Reputation point
    2025-12-03T22:59:09.8366667+00:00

    According to the azure app service sidecar documentation, the default value for the inheritAppSettingsAndConnectionStrings sidecar setting is true, so when unset, it the sidecar should inherit the main environment variables. This is the case when using ARM templates, the Azure CLI and the like.

    However, when the box is unchecked in the portal, it is set to false, which results in the sidecar * not * inheriting the environment variables. If you make any updates to the sidecar in the portal, the default then becomes inheritAppSettingsAndConnectionStrings=false, but if you update it with the CLI the inheritAppSettingsAndConnectionStrings=undefined which defaults to true.

    This effectively means that the portal and automation tools have the opposite defaults * and * that the difference is indistinguishable in the portal (since both undefined and false result in an un-checked checkbox) ! Hence you may have no way of knowing the difference between the two un-checked behaviors, -- and even worse, unrelated changes to the app service in the portal may update the default value from undefined to false.

    So in short, good luck to you, and don't trust the inheritAppSettingsAndConnectionStrings setting, so you may want to set environment variables for the sidecar right there in the sidecar settings (which you can do).

    0 comments No comments

Your answer

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