Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added short region name to the execution context #627

Merged
merged 3 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/Abstractions/ExecutionContext/BaseExecutionContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ namespace Microsoft.Omex.Extensions.Abstractions.ExecutionContext
/// </summary>
public class BaseExecutionContext : IExecutionContext
{
// Defined by Azure https://whatazurewebsiteenvironmentvariablesareavailable.azurewebsites.net/
// Set as an environment variable (e.g. through ARM template deployment)
internal const string RegionNameVariableName = "REGION_NAME";

// We define them
internal const string RegionShortNameVariableName = "REGION_SHORT_NAME";
internal const string ClusterNameVariableName = "CLUSTER_NAME";
internal const string SliceNameVariableName = "SLICE_NAME";
internal const string AspNetCoreEnviromentVariableName = "ASPNETCORE_ENVIRONMENT";
Expand All @@ -42,6 +41,7 @@ public BaseExecutionContext(IHostEnvironment? hostEnvironment = null)
ClusterIpAddress = GetIpAddress(MachineName);

RegionName = GetVariable(RegionNameVariableName) ?? DefaultEmptyValue;
RegionShortName = GetVariable(RegionShortNameVariableName) ?? DefaultEmptyValue;
DeploymentSlice = GetVariable(SliceNameVariableName) ?? DefaultEmptyValue;

if (hostEnvironment != null)
Expand Down Expand Up @@ -103,6 +103,9 @@ public BaseExecutionContext(IHostEnvironment? hostEnvironment = null)
/// <inheritdoc/>
public string RegionName { get; protected set; }

/// <inheritdoc/>
public string RegionShortName { get; protected set; }

/// <inheritdoc/>
public string ServiceName { get; protected set; }

Expand Down
5 changes: 5 additions & 0 deletions src/Abstractions/ExecutionContext/IExecutionContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ public interface IExecutionContext
/// </summary>
string RegionName { get; }

/// <summary>
/// The short Azure region name
/// </summary>
string RegionShortName { get; }

/// <summary>
/// The service name
/// </summary>
Expand Down