Skip to content

Commit 142c288

Browse files
authored
Support logicapps pwsh version setting (#11105)
* Support logicapps pwsh version setting * Update release notes
1 parent e8e1adc commit 142c288

File tree

5 files changed

+37
-5
lines changed

5 files changed

+37
-5
lines changed

release_notes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
- My change description (#PR)
55
-->
66
- Update Java Worker Version to [2.19.1](https://github.com/Azure/azure-functions-java-worker/releases/tag/2.19.1)
7+
- Support `LOGIC_APPS_POWERSHELL_VERSION` when resolving powershell's `worker.config.json` for logic-app apps only. (#11105)
78
- Update Python Worker Version to [4.38.0](https://github.com/Azure/azure-functions-python-worker/releases/tag/4.38.0)

src/WebJobs.Script/Workers/Rpc/Configuration/RpcWorkerConfigFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ internal void AddProvider(string workerDir)
144144

145145
// Check if any app settings are provided for that language
146146
var languageSection = _config.GetSection($"{RpcWorkerConstants.LanguageWorkersSectionName}:{workerDescription.Language}");
147-
workerDescription.Arguments = workerDescription.Arguments ?? new List<string>();
147+
workerDescription.Arguments ??= new List<string>();
148148
GetWorkerDescriptionFromAppSettings(workerDescription, languageSection);
149149
AddArgumentsFromAppSettings(workerDescription, languageSection);
150150

src/WebJobs.Script/Workers/Rpc/RpcWorkerConstants.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public static class RpcWorkerConstants
1111
public const string FunctionWorkerRuntimeVersionSettingName = "FUNCTIONS_WORKER_RUNTIME_VERSION";
1212
public const string FunctionsWorkerProcessCountSettingName = "FUNCTIONS_WORKER_PROCESS_COUNT";
1313
public const string FunctionsWorkerSharedMemoryDataTransferEnabledSettingName = "FUNCTIONS_WORKER_SHARED_MEMORY_DATA_TRANSFER_ENABLED";
14+
public const string LogicAppsPowerShellVersionSettingName = "LOGIC_APPS_POWERSHELL_VERSION";
1415

1516
// Comma-separated list of directories where shared memory maps can be created for data transfer between host and worker.
1617
// This will override the default directories.

src/WebJobs.Script/Workers/Rpc/RpcWorkerDescription.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,15 @@ private void ValidateOSPlatform(OSPlatform os)
137137
{
138138
if (!SupportedOperatingSystems.Any(s => s.Equals(os.ToString(), StringComparison.OrdinalIgnoreCase)))
139139
{
140-
throw new PlatformNotSupportedException($"OS {os.ToString()} is not supported for language {Language}");
140+
throw new PlatformNotSupportedException($"OS {os} is not supported for language {Language}");
141141
}
142142
}
143143

144144
private void ValidateArchitecture(Architecture architecture)
145145
{
146146
if (!SupportedArchitectures.Any(s => s.Equals(architecture.ToString(), StringComparison.OrdinalIgnoreCase)))
147147
{
148-
throw new PlatformNotSupportedException($"Architecture {architecture.ToString()} is not supported for language {Language}");
148+
throw new PlatformNotSupportedException($"Architecture {architecture} is not supported for language {Language}");
149149
}
150150
}
151151

@@ -192,9 +192,20 @@ internal void FormatWorkerPathIfNeeded(ISystemRuntimeInformation systemRuntimeIn
192192

193193
OSPlatform os = systemRuntimeInformation.GetOSPlatform();
194194
Architecture architecture = systemRuntimeInformation.GetOSArchitecture();
195+
195196
string workerRuntime = environment.GetEnvironmentVariable(RpcWorkerConstants.FunctionWorkerRuntimeSettingName);
196-
string version = environment.GetEnvironmentVariable(RpcWorkerConstants.FunctionWorkerRuntimeVersionSettingName);
197-
logger.LogDebug($"EnvironmentVariable {RpcWorkerConstants.FunctionWorkerRuntimeVersionSettingName}: {version}");
197+
198+
string workerRuntimeVersionSettingName = RpcWorkerConstants.FunctionWorkerRuntimeVersionSettingName;
199+
200+
// For LogicApps and the powershell worker config, we special case a separate environment variable.
201+
if (environment.IsLogicApp() && string.Equals(
202+
Language, RpcWorkerConstants.PowerShellLanguageWorkerName, StringComparison.Ordinal))
203+
{
204+
workerRuntimeVersionSettingName = RpcWorkerConstants.LogicAppsPowerShellVersionSettingName;
205+
}
206+
207+
string version = environment.GetEnvironmentVariable(workerRuntimeVersionSettingName);
208+
logger.LogDebug($"EnvironmentVariable {workerRuntimeVersionSettingName}: {version}");
198209

199210
// Only over-write DefaultRuntimeVersion if workerRuntime matches language for the worker config
200211
if (!string.IsNullOrEmpty(workerRuntime) && workerRuntime.Equals(Language, StringComparison.OrdinalIgnoreCase) && !string.IsNullOrEmpty(version))

test/WebJobs.Script.Tests/Workers/Rpc/RpcWorkerConfigFactoryTests.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,25 @@ public void DefaultWorkerConfigs_Overrides_VersionAppSetting()
185185
Assert.Equal("7.4", powershellWorkerConfig.Description.DefaultRuntimeVersion);
186186
}
187187

188+
[Fact]
189+
public void LogicApps_Overrides_PowershellVersionSetting()
190+
{
191+
var testEnvironment = new TestEnvironment();
192+
testEnvironment.SetEnvironmentVariable("APP_KIND", "workflowapp");
193+
testEnvironment.SetEnvironmentVariable("FUNCTIONS_WORKER_RUNTIME_VERSION", "7.2");
194+
testEnvironment.SetEnvironmentVariable("LOGIC_APPS_POWERSHELL_VERSION", "7.4");
195+
var configBuilder = ScriptSettingsManager.CreateDefaultConfigurationBuilder();
196+
var config = configBuilder.Build();
197+
var scriptSettingsManager = new ScriptSettingsManager(config);
198+
var testLogger = new TestLogger("test");
199+
var configFactory = new RpcWorkerConfigFactory(config, testLogger, _testSysRuntimeInfo, testEnvironment, new TestMetricsLogger(), _testWorkerProfileManager);
200+
var workerConfigs = configFactory.GetConfigs();
201+
var powershellWorkerConfig = workerConfigs.FirstOrDefault(w => w.Description.Language.Equals("powershell", StringComparison.OrdinalIgnoreCase));
202+
Assert.Equal(4, workerConfigs.Count);
203+
Assert.NotNull(powershellWorkerConfig);
204+
Assert.Equal("7.4", powershellWorkerConfig.Description.DefaultRuntimeVersion);
205+
}
206+
188207
[Theory]
189208
[InlineData("python", "Python", false, true)]
190209
[InlineData("python", "NOde", false, false)]

0 commit comments

Comments
 (0)