diff --git a/src/WebJobs.Script/DependencyInjection/ScriptStartupTypeLocator.cs b/src/WebJobs.Script/DependencyInjection/ScriptStartupTypeLocator.cs index 443e2ba807..3cd21a829d 100644 --- a/src/WebJobs.Script/DependencyInjection/ScriptStartupTypeLocator.cs +++ b/src/WebJobs.Script/DependencyInjection/ScriptStartupTypeLocator.cs @@ -207,6 +207,12 @@ public async Task> GetExtensionsStartupTypesAsync() if (extensionType == null) { _logger.ScriptStartUpUnableToLoadExtension(startupExtensionName, extensionItem.TypeName); + + // Log an error if the extension is not loaded and the extension is not a built-in extension, not modifying the existing log. + _logger.ScriptStartUpUnableToLoadExtensionError(startupExtensionName, extensionItem.TypeName); + + string message = $"The extension '{startupExtensionName}' (Type: '{extensionItem.TypeName}') failed to load. Triggers associated with this extension will not function, though other triggers may still work. This issue suggests that your deployment package was built incorrectly."; + DiagnosticEventLoggerExtensions.LogDiagnosticEventError(_logger, DiagnosticEventConstants.ExtensionsStartupTypesErrorCode, message, DiagnosticEventConstants.ExtensionsStartupTypesHelpLink, new Exception(message)); continue; } diff --git a/src/WebJobs.Script/Diagnostics/DiagnosticEventConstants.cs b/src/WebJobs.Script/Diagnostics/DiagnosticEventConstants.cs index 2669a22a6b..f6efdf08dc 100644 --- a/src/WebJobs.Script/Diagnostics/DiagnosticEventConstants.cs +++ b/src/WebJobs.Script/Diagnostics/DiagnosticEventConstants.cs @@ -34,5 +34,8 @@ internal static class DiagnosticEventConstants public const string WorkerRuntimeDoesNotMatchWithFunctionMetadataErrorCode = "AZFD0013"; public const string WorkerRuntimeDoesNotMatchWithFunctionMetadataHelpLink = "https://aka.ms/functions-invalid-worker-runtime"; + + public const string ExtensionsStartupTypesErrorCode = "AZFD0014"; + public const string ExtensionsStartupTypesHelpLink = "https://aka.ms/functions-deployment-technologies"; } } diff --git a/src/WebJobs.Script/Diagnostics/Extensions/LoggerExtension.cs b/src/WebJobs.Script/Diagnostics/Extensions/LoggerExtension.cs index a887ecf88a..1fab5fee55 100644 --- a/src/WebJobs.Script/Diagnostics/Extensions/LoggerExtension.cs +++ b/src/WebJobs.Script/Diagnostics/Extensions/LoggerExtension.cs @@ -45,7 +45,7 @@ internal static class LoggerExtension LoggerMessage.Define(LogLevel.Warning, new EventId(306, nameof(ScriptStartUpUnableToLoadExtension)), "Unable to load startup extension '{startupExtensionName}' (Type: '{typeName}'). The type does not exist. Please validate the type and assembly names."); - + private static readonly Action _scriptStartUpTypeIsNotValid = LoggerMessage.Define(LogLevel.Warning, new EventId(307, nameof(ScriptStartUpTypeIsNotValid)), @@ -193,6 +193,11 @@ internal static class LoggerExtension new EventId(339, nameof(NoHostJsonFile)), "No functions were found. This can occur before you deploy code to your function app or when the host.json file is missing from the most recent deployment. Make sure that your deployment package includes the host.json file in the root of the package. For deployment package requirements, see https://aka.ms/functions-deployment-technologies."); + private static readonly Action _scriptStartUpUnableToLoadExtensionError = + LoggerMessage.Define(LogLevel.Error, + new EventId(340, nameof(ScriptStartUpUnableToLoadExtensionError)), + "The extension '{startupExtensionName}' (Type: '{typeName}') failed to load. Triggers associated with this extension will not function, though other triggers may still work. This issue suggests that your deployment package was built incorrectly. For deployment package requirements, see https://aka.ms/functions-deployment-technologies."); + private static readonly Action _publishingMetrics = LoggerMessage.Define(LogLevel.Debug, new EventId(338, nameof(PublishingMetrics)), "{metrics}"); @@ -251,6 +256,11 @@ public static void ScriptStartUpUnableToLoadExtension(this ILogger logger, strin _scriptStartUpUnableToLoadExtension(logger, startupExtensionName, typeName, null); } + public static void ScriptStartUpUnableToLoadExtensionError(this ILogger logger, string startupExtensionName, string typeName) + { + _scriptStartUpUnableToLoadExtensionError(logger, startupExtensionName, typeName, null); + } + public static void ScriptStartUpTypeIsNotValid(this ILogger logger, string typeName, string startupClassName, string startupConfigurationClassName) { _scriptStartUpTypeIsNotValid(logger, typeName, startupClassName, startupConfigurationClassName, null);