-
Notifications
You must be signed in to change notification settings - Fork 469
Emit diagnostic warning for deprecated Azure Functions Proxies usage #11405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Copilot
wants to merge
3
commits into
dev
Choose a base branch
from
copilot/fix-959cd81d-56d3-4a58-8a12-47e65f9bdeea
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+54
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -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,48 @@ public async Task ProxyMetadata_WhenProxyFileChanges_IsRefreshed() | |||||||||||||||||||||||||
Assert.Equal(20, proxyMetadata3.Length); | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
[Fact] | ||||||||||||||||||||||||||
public async Task ProxyFunctionProvider_WhenProxiesEnabled_EmitsDiagnosticWarning() | ||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||
using (var tempDirectory = new TempDirectory()) | ||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||
var testProxiesPath = Path.Combine(Environment.CurrentDirectory, @"TestScripts\Proxies"); | ||||||||||||||||||||||||||
var options = new OptionsWrapper<ScriptJobHostOptions>(new ScriptJobHostOptions | ||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||
RootScriptPath = tempDirectory.Path | ||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
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); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
// Copy proxies definition to trigger the warning | ||||||||||||||||||||||||||
FileUtility.CopyDirectory(testProxiesPath, tempDirectory.Path); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
// Get metadata to trigger loading of proxies and the diagnostic warning | ||||||||||||||||||||||||||
ImmutableArray<FunctionMetadata> proxyMetadata = await provider.GetFunctionMetadataAsync(); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
// Verify proxies were loaded | ||||||||||||||||||||||||||
Assert.NotEmpty(proxyMetadata); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
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); | ||||||||||||||||||||||||||
Comment on lines
+96
to
+100
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nitpick] The LINQ query for finding the warning log is complex and hard to read. Consider extracting this into a helper method or breaking it into multiple steps with intermediate variables for better readability.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
Assert.NotNull(warningLog); | ||||||||||||||||||||||||||
Assert.Contains("Azure Functions Proxies are deprecated", warningLog.FormattedMessage); | ||||||||||||||||||||||||||
Assert.Contains("September 30, 2025", warningLog.FormattedMessage); | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] This warning message is very long (over 200 characters) and should be broken into multiple lines for better readability. Consider using string interpolation or multiline string formatting to improve maintainability.
Copilot uses AI. Check for mistakes.