in src/Abstractions/ExecutionContext/BaseExecutionContext.cs [37:77]
public BaseExecutionContext(IHostEnvironment? hostEnvironment = null)
{
MachineName = GetMachineName();
BuildVersion = GetBuildVersion();
ClusterIpAddress = GetIpAddress(MachineName);
RegionName = GetVariable(RegionNameVariableName) ?? DefaultEmptyValue;
DeploymentSlice = GetVariable(SliceNameVariableName) ?? DefaultEmptyValue;
if (hostEnvironment != null)
{
EnvironmentName = hostEnvironment.EnvironmentName ?? DefaultEmptyValue;
IsPrivateDeployment = hostEnvironment.IsDevelopment();
}
else
{
EnvironmentName = GetVariable(AspNetCoreEnviromentVariableName)
?? GetVariable(DotNetEnviromentVariableName)
?? Environments.Development;
IsPrivateDeployment = string.Equals(EnvironmentName, Environments.Development, StringComparison.OrdinalIgnoreCase);
}
IsCanary = false;
// Service Fabric specific values
ServiceName = GetVariable(ServiceNameVariableName) ?? DefaultEmptyValue;
ApplicationName = GetVariable(ApplicationNameVariableName) ?? DefaultEmptyValue;
NodeName = GetVariable(NodeNameVariableName) ?? DefaultEmptyValue;
MachineId = FormattableString.Invariant($"{MachineName}_{NodeName}");
string? nodeIPAddressOrFQDN = GetVariable(NodeIPOrFQDNVariableName);
if (IPAddress.TryParse(nodeIPAddressOrFQDN, out IPAddress? ipAddress))
{
ClusterIpAddress = ipAddress;
}
Cluster = GetVariable(ClusterNameVariableName) ?? nodeIPAddressOrFQDN ?? MachineId;
}