Skip to content

Commit f416b27

Browse files
TonewallTony Choibrettsam
authored
Fix Blob Trigger Error (#9419)
Co-authored-by: Tony Choi <[email protected]> Co-authored-by: Brett Samblanet <[email protected]>
1 parent c643fb6 commit f416b27

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

src/WebJobs.Script/Extensions/FunctionMetadataExtensions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ public static bool IsLegacyBlobTriggerFunction(this FunctionMetadata metadata)
5555
return !string.Equals(token.ToString(), BlobEventGridSourceValue, StringComparison.OrdinalIgnoreCase);
5656
}
5757
}
58+
return true;
5859
}
59-
return true;
60+
return false;
6061
}
6162

6263
public static string GetFunctionId(this FunctionMetadata metadata)

test/WebJobs.Script.Tests/ScriptHostTests.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,6 +1452,39 @@ public void ValidateFunction_ThrowsForLegacyBlobTrigger_OnFlexConsumption()
14521452
ScriptHost.ValidateFunction(function.Object, httpFunctions, testEnvironment);
14531453
}
14541454

1455+
[Fact]
1456+
public void ValidateFunction_DoesntThrowForHttpTrigger_OnFlexConsumption()
1457+
{
1458+
var httpFunctions = new Dictionary<string, HttpTriggerAttribute>();
1459+
var name = "test";
1460+
1461+
BindingMetadata httpTriggerMetadata = BindingMetadata.Create(JObject.Parse("{\"type\": \"httpTrigger\",\"name\": \"req\",\"direction\": \"in\"}"));
1462+
1463+
var metadata = new FunctionMetadata();
1464+
metadata.Bindings.Add(httpTriggerMetadata);
1465+
var function = new Mock<FunctionDescriptor>(MockBehavior.Strict, name, null, metadata, null, null, null, null);
1466+
function.SetupGet(p => p.HttpTriggerAttribute).Returns(() => null);
1467+
1468+
TestEnvironment testEnvironment = new TestEnvironment();
1469+
testEnvironment.SetEnvironmentVariable(EnvironmentSettingNames.AzureWebsiteSku, ScriptConstants.FlexConsumptionSku);
1470+
1471+
var exception = Record.Exception(() =>
1472+
{
1473+
ScriptHost.ValidateFunction(function.Object, httpFunctions, testEnvironment);
1474+
});
1475+
Assert.Null(exception);
1476+
1477+
metadata.Bindings.Clear();
1478+
1479+
exception = Record.Exception(() =>
1480+
{
1481+
ScriptHost.ValidateFunction(function.Object, httpFunctions, testEnvironment);
1482+
});
1483+
Assert.Null(exception);
1484+
1485+
ScriptHost.ValidateFunction(function.Object, httpFunctions, testEnvironment);
1486+
}
1487+
14551488
[Fact]
14561489
public async Task IsFunction_ReturnsExpectedResult()
14571490
{

0 commit comments

Comments
 (0)