Skip to content

Commit f7835b0

Browse files
committed
taking into account logic app configuration for bundles
1 parent ad84187 commit f7835b0

File tree

3 files changed

+33
-13
lines changed

3 files changed

+33
-13
lines changed

src/WebJobs.Script/DependencyInjection/ScriptStartupTypeLocator.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,18 +103,20 @@ public async Task<IEnumerable<Type>> GetExtensionsStartupTypesAsync()
103103
}
104104
}
105105

106-
bool isDotnetApp = isPrecompiledFunctionApp || IsDotnetIsolatedApp(workerConfigs);
106+
bool isDotnetIsolatedApp = IsDotnetIsolatedApp(workerConfigs);
107+
bool isDotnetApp = isPrecompiledFunctionApp || isDotnetIsolatedApp;
108+
var isLogicApp = SystemEnvironment.Instance.IsLogicApp();
107109

108110
if (SystemEnvironment.Instance.IsPlaceholderModeEnabled())
109111
{
110112
// Do not move this.
111113
// Calling this log statement in the placeholder mode to avoid jitting during specializtion
112-
_logger.ScriptStartNotLoadingExtensionBundle("WARMUP_LOG_ONLY", bundleConfigured, isPrecompiledFunctionApp, isLegacyExtensionBundle);
114+
_logger.ScriptStartNotLoadingExtensionBundle("WARMUP_LOG_ONLY", bundleConfigured, isPrecompiledFunctionApp, isLegacyExtensionBundle, isDotnetIsolatedApp, isLogicApp);
113115
}
114116

115117
string baseProbingPath = null;
116118

117-
if (bundleConfigured && (!isDotnetApp || isLegacyExtensionBundle))
119+
if (bundleConfigured && (!isDotnetApp || isLegacyExtensionBundle || isLogicApp))
118120
{
119121
extensionsMetadataPath = await _extensionBundleManager.GetExtensionBundleBinPathAsync();
120122
if (string.IsNullOrEmpty(extensionsMetadataPath))
@@ -130,9 +132,9 @@ public async Task<IEnumerable<Type>> GetExtensionsStartupTypesAsync()
130132
extensionsMetadataPath = Path.Combine(_rootScriptPath, "bin");
131133
if (Utility.TryResolveExtensionsMetadataPath(_rootScriptPath, out string resolvedPath, out baseProbingPath))
132134
{
133-
extensionsMetadataPath = resolvedPath;
135+
extensionsMetadataPath = resolvedPath;
134136
}
135-
_logger.ScriptStartNotLoadingExtensionBundle(extensionsMetadataPath, bundleConfigured, isPrecompiledFunctionApp, isLegacyExtensionBundle);
137+
_logger.ScriptStartNotLoadingExtensionBundle(extensionsMetadataPath, bundleConfigured, isPrecompiledFunctionApp, isLegacyExtensionBundle, isDotnetIsolatedApp, isLogicApp);
136138
}
137139

138140
baseProbingPath ??= extensionsMetadataPath;

src/WebJobs.Script/Diagnostics/Extensions/LoggerExtension.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,10 @@ internal static class LoggerExtension
161161
new EventId(333, nameof(IncorrectAutorestGeneratedJsonFile)),
162162
"autorest_generated.json file found is incorrect (https://aka.ms/stencil) | exception:\n{contents}");
163163

164-
private static readonly Action<ILogger, string, bool, bool, bool, Exception> _scriptStartUpNotLoadingExtensionBundle =
165-
LoggerMessage.Define<string, bool, bool, bool>(LogLevel.Information,
164+
private static readonly Action<ILogger, string, bool, bool, bool, bool, bool, Exception> _scriptStartUpNotLoadingExtensionBundle =
165+
LoggerMessage.Define<string, bool, bool, bool, bool, bool>(LogLevel.Information,
166166
new EventId(334, nameof(ScriptStartNotLoadingExtensionBundle)),
167-
"Loading extensions from {path}. BundleConfigured: {bundleConfigured}, PrecompiledFunctionApp: {isPrecompiledFunctionApp}, LegacyBundle: {isLegacyExtensionBundle}");
167+
"Loading extensions from {path}. BundleConfigured: {bundleConfigured}, PrecompiledFunctionApp: {isPrecompiledFunctionApp}, LegacyBundle: {isLegacyExtensionBundle}, DotnetIsolatedApp: {isDotnetIsolatedApp}, isLogicApp: {isLogicApp}");
168168

169169
private static readonly Action<ILogger, string, Exception> _scriptStartupResettingLoadContextWithBasePath =
170170
LoggerMessage.Define<string>(LogLevel.Information,
@@ -208,9 +208,9 @@ public static void ScriptStartupResettingLoadContextWithBasePath(this ILogger lo
208208
_scriptStartupResettingLoadContextWithBasePath(logger, path, null);
209209
}
210210

211-
public static void ScriptStartNotLoadingExtensionBundle(this ILogger logger, string path, bool bundleConfigured, bool isPrecompiledFunctionApp, bool isLegacyExtensionBundle)
211+
public static void ScriptStartNotLoadingExtensionBundle(this ILogger logger, string path, bool bundleConfigured, bool isPrecompiledFunctionApp, bool isLegacyExtensionBundle, bool isDotnetIsolatedApp, bool isLogicApp)
212212
{
213-
_scriptStartUpNotLoadingExtensionBundle(logger, path, bundleConfigured, isPrecompiledFunctionApp, isLegacyExtensionBundle, null);
213+
_scriptStartUpNotLoadingExtensionBundle(logger, path, bundleConfigured, isPrecompiledFunctionApp, isLegacyExtensionBundle, isDotnetIsolatedApp, isLogicApp, null);
214214
}
215215

216216
public static void ScriptStartUpLoadingStartUpExtension(this ILogger logger, string startupExtensionName)

test/WebJobs.Script.Tests/ScriptStartupTypeDiscovererTests.cs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,10 +392,20 @@ public async Task GetExtensionsStartupTypes_LegacyBundles_UsesExtensionBundleBin
392392
}
393393
}
394394

395-
[Fact]
396-
public async Task GetExtensionsStartupTypes_DotnetIsolated_ExtensionBundleConfigured()
395+
[Theory]
396+
[InlineData(true)]
397+
[InlineData(false)]
398+
public async Task GetExtensionsStartupTypes_DotnetIsolated_ExtensionBundleConfigured(bool isLogicApp)
397399
{
400+
var vars = new Dictionary<string, string>();
401+
402+
if (isLogicApp)
403+
{
404+
vars.Add(EnvironmentSettingNames.AppKind, ScriptConstants.WorkFlowAppKind);
405+
}
406+
398407
using (var directory = GetTempDirectory())
408+
using (var env = new TestScopedEnvironmentVariable(vars))
399409
{
400410
var binPath = Path.Combine(directory.Path, "bin");
401411
TestMetricsLogger testMetricsLogger = new TestMetricsLogger();
@@ -428,7 +438,15 @@ public async Task GetExtensionsStartupTypes_DotnetIsolated_ExtensionBundleConfig
428438
//Assert
429439
var traces = testLoggerProvider.GetAllLogMessages();
430440
var expectedTrace = traces.FirstOrDefault(val => val.EventId.Name.Equals("ScriptStartNotLoadingExtensionBundle"));
431-
Assert.NotNull(expectedTrace);
441+
442+
if (isLogicApp)
443+
{
444+
Assert.Null(expectedTrace);
445+
}
446+
else
447+
{
448+
Assert.NotNull(expectedTrace);
449+
}
432450

433451
AreExpectedMetricsGenerated(testMetricsLogger);
434452
Assert.Single(types);

0 commit comments

Comments
 (0)