diff --git a/src/WebJobs.Script/Diagnostics/DiagnosticEventConstants.cs b/src/WebJobs.Script/Diagnostics/DiagnosticEventConstants.cs index 2669a22a6b..ff58e47915 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 DeprecatedProxiesErrorCode = "AZFD0014"; + public const string DeprecatedProxiesHelpLink = "https://azure.microsoft.com/en-us/updates?id=community-support-for-azure-functions-proxies-will-end-on-30-september-2025"; } } diff --git a/src/WebJobs.Script/Host/ProxyFunctionProvider.cs b/src/WebJobs.Script/Host/ProxyFunctionProvider.cs index 01cdc36720..59da1d4fbc 100644 --- a/src/WebJobs.Script/Host/ProxyFunctionProvider.cs +++ b/src/WebJobs.Script/Host/ProxyFunctionProvider.cs @@ -14,6 +14,7 @@ using Microsoft.Azure.AppService.Proxy.Client; using Microsoft.Azure.WebJobs.Logging; using Microsoft.Azure.WebJobs.Script.Description; +using Microsoft.Azure.WebJobs.Script.Diagnostics; using Microsoft.Azure.WebJobs.Script.Eventing; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; @@ -41,6 +42,8 @@ public ProxyFunctionProvider(IOptions scriptOptions, IEnvi _logger = loggerFactory.CreateLogger(LogCategories.Startup); if (_environment.IsProxiesEnabled()) { + _logger.LogDiagnosticEventWarning(DiagnosticEventConstants.DeprecatedProxiesErrorCode, "Azure Functions Proxies are deprecated and community support will end on September 30, 2025. Please migrate to Azure API Management or Azure Container Apps. See https://azure.microsoft.com/en-us/updates?id=community-support-for-azure-functions-proxies-will-end-on-30-september-2025 for more information.", DiagnosticEventConstants.DeprecatedProxiesHelpLink, null); + if (_environment.IsFlexConsumptionSku()) { _logger.LogWarning("Proxies are not supported in Flex Consumption. Proxy definitions will be ignored."); diff --git a/test/WebJobs.Script.Tests/ProxyFunctionProviderTests.cs b/test/WebJobs.Script.Tests/ProxyFunctionProviderTests.cs index 9f5b799546..5b0de64a7b 100644 --- a/test/WebJobs.Script.Tests/ProxyFunctionProviderTests.cs +++ b/test/WebJobs.Script.Tests/ProxyFunctionProviderTests.cs @@ -10,6 +10,7 @@ using System.Threading.Tasks; using Microsoft.Azure.WebJobs.Script.Description; using Microsoft.Azure.WebJobs.Script.Eventing; +using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Options; using WebJobs.Script.Tests; @@ -60,5 +61,35 @@ public async Task ProxyMetadata_WhenProxyFileChanges_IsRefreshed() Assert.Equal(20, proxyMetadata3.Length); } } + + [Fact] + public void ProxyFunctionProvider_WhenProxiesEnabled_EmitsDiagnosticWarning() + { + var options = new OptionsWrapper(new ScriptJobHostOptions + { + RootScriptPath = Path.GetTempPath() + }); + + var environment = new TestEnvironment(new Dictionary + { + { EnvironmentSettingNames.AzureWebJobsFeatureFlags, ScriptConstants.FeatureFlagEnableProxies }, + }); + var eventManager = new ScriptEventManager(); + var loggerFactory = new LoggerFactory(); + var testLogger = new TestLogger("Startup"); + loggerFactory.AddProvider(new TestLoggerProvider(testLogger)); + + var provider = new ProxyFunctionProvider(options, environment, eventManager, loggerFactory); + + var warningLog = testLogger.GetLogMessages().FirstOrDefault(m => + m.Level == LogLevel.Warning && + m.State is IDictionary state && + state.ContainsKey(ScriptConstants.ErrorCodeKey) && + state[ScriptConstants.ErrorCodeKey].ToString() == DiagnosticEventConstants.DeprecatedProxiesErrorCode); + + Assert.NotNull(warningLog); + Assert.Contains("Azure Functions Proxies are deprecated", warningLog.FormattedMessage); + Assert.Contains("September 30, 2025", warningLog.FormattedMessage); + } } }