microsoft / service-fabric-issues

This repo is for the reporting of issues found with Azure Service Fabric.
168 stars 21 forks source link

Application could not access machine level environment variables on Linux #1694

Closed vijaycnarayan closed 4 years ago

vijaycnarayan commented 4 years ago

I am running Service Fabric inside a docker container on WSL2 (Ubuntu) and I am passing environment variables via docker run --env VAR1="test" However, I could not access VAR1 in my application that is published to the Service Fabric (SF) instance.

The same behavior is seen when running the application in Azure Linux SF cluster where the environment variables are defined at the machine level. export VAR1="test"

Expected Behavior

The service that is running within the Service Fabric should be able to access the machine level environment variables on the Linux box.

Current Behavior

I can only see SF default environment variables within my application. No other environment variables are accessible. The workaround is to define them in the manifest and access them via InProcess but I do not want to do that. Since I am able to access the machine level environment variables on Windows, I am expecting the same behavior on Linux.

Steps to Reproduce

  1. Run SF inside WSL2 (Ubuntu) or in Azure Linux SF cluster
  2. Define machine level environment variables by passing them via docker run or defining them within the docker file or even using export VAR1="test" on the box directly.
  3. The application that is running on this SF instance should be able to read machine level environment variables but it could not.

Context (Environment)

I am running Service Fabric on Windows but planning to migrate to Linux. I am expecting same behavior on Linux where the application (running inside SF) should be able to read Machine level environment variables on Linux (similar to Windows).

Service Fabric Runtime and SDK Version :

Latest

Operating System :

WSL2 (Ubuntu) Docker or Azure SF Linux Cluster

1 or more

Possible Workaround

To define environment variables in manifest file and access them by setting EnvironmentVariableTarget as Process; but this is not I would want to do. Environment.GetEnvironmentVariable("VAR1", EnvironmentVariableTarget.Process);

vijaycnarayan commented 4 years ago

Looks like its an expected behavior that .net core applications running on Linux cannot access Machine level environment variables.