Do not send any content if root is pinged by scale controller
MODIFY
src/WebJobs.Script.WebHost/Controllers/FunctionsController.cs
src/WebJobs.Script.WebHost/Controllers/FunctionsController.cs
@@ -52,7 +52,7 @@ public override async Task<HttpResponseMessage> ExecuteAsync(HttpControllerConte
{
// if the request is to the root and we can't find any matching FunctionDescriptors which might have been setup by proxies
// then homepage logic will be applied.
- return IsHomepageDisabled
+ return (IsHomepageDisabled || request.IsAntaresInternalRequest())
? new HttpResponseMessage(HttpStatusCode.NoContent)
: new HttpResponseMessage(HttpStatusCode.OK)
{

MODIFY
test/WebJobs.Script.Tests.Integration/SamplesEndToEndTests.cs
test/WebJobs.Script.Tests.Integration/SamplesEndToEndTests.cs
@@ -210,6 +210,22 @@ public async Task Home_Get_WithHomepageDisabled_Succeeds()
}
}
+ [Fact]
+ public async Task Home_Get_InAzureEnvironment_AsInternalRequest_ReturnsNoContent()
+ {
+ // Pings to the site root should not return the homepage content if they are internal requests.
+ // This test sets a website instance Id which means that we'll go down the IsAzureEnvironment = true codepath
+ // but the sent request does NOT include an X-ARR-LOG-ID header. This indicates the request was internal.
+
+ using (new TestScopedSettings(_settingsManager, EnvironmentSettingNames.AzureWebsiteInstanceId, "123"))
+ {
+ HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, string.Empty);
+
+ HttpResponseMessage response = await this._fixture.HttpClient.SendAsync(request);
+ Assert.Equal(HttpStatusCode.NoContent, response.StatusCode);
+ }
+ }
+
[Fact]
public async Task HttpTrigger_CSharp_Poco_Post_Succeeds()
{

Do not send any content if root is pinged by scale controller