Skip to content
Draft
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
3 changes: 3 additions & 0 deletions src/WebJobs.Script/Diagnostics/DiagnosticEventConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
}
3 changes: 3 additions & 0 deletions src/WebJobs.Script/Host/ProxyFunctionProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -41,6 +42,8 @@ public ProxyFunctionProvider(IOptions<ScriptJobHostOptions> scriptOptions, IEnvi
_logger = loggerFactory.CreateLogger(LogCategories.Startup);
if (_environment.IsProxiesEnabled())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there other places in the host we do this check?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The warning here will be emitted simply if proxies feature flag is enabled. We may need to only emit warning if there are actual files with proxies. Otherwise, customers might be confused why the warning is generated. If we do want the warning here we also should provide instructions to remove feature flag.

{
_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.");
Expand Down
31 changes: 31 additions & 0 deletions test/WebJobs.Script.Tests/ProxyFunctionProviderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<ScriptJobHostOptions>(new ScriptJobHostOptions
{
RootScriptPath = Path.GetTempPath()
});

var environment = new TestEnvironment(new Dictionary<string, string>
{
{ 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<string, object> 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);
}
}
}