EventGrid Trigger execution failed with NotImplementedException (#104)

This commit is contained in:
Alexey Rodionov 2022-10-20 16:54:08 -07:00 коммит произвёл GitHub
Родитель 5f13e2511a
Коммит 5de7c7e86a
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 35 добавлений и 1 удалений

Просмотреть файл

@ -3,7 +3,7 @@
<TargetFramework>netstandard2.0</TargetFramework>
<PackageId>Microsoft.Azure.WebJobs.Extensions.EventGrid</PackageId>
<Description>This extension adds bindings for EventGrid</Description>
<Version>2.1.0$(VersionSuffix)</Version>
<Version>2.1.1$(VersionSuffix)</Version>
<CommitHash Condition="$(CommitHash) == ''">N/A</CommitHash>
<InformationalVersion>$(Version) Commit hash: $(CommitHash)</InformationalVersion>
<AssemblyName>Microsoft.Azure.WebJobs.Extensions.EventGrid</AssemblyName>

Просмотреть файл

@ -67,6 +67,7 @@ namespace Microsoft.Azure.WebJobs.Extensions.EventGrid
.AddConverter<JToken, string>((jtoken) => jtoken.ToString(Formatting.Indented))
.AddConverter<JToken, string[]>((jarray) => jarray.Select(ar => ar.ToString(Formatting.Indented)).ToArray())
.AddConverter<JToken, DirectInvokeString>((jtoken) => new DirectInvokeString(null))
.AddConverter<DirectInvokeString, JToken>(directInvokeString => JToken.Parse(directInvokeString.Value))
.AddConverter<JToken, EventGridEvent>((jobject) => jobject.ToObject<EventGridEvent>()) // surface the type to function runtime
.AddConverter<JToken, EventGridEvent[]>((jobject) => jobject.ToObject<EventGridEvent[]>()) // surface the type to function runtime
.AddOpenConverter<JToken, OpenType.Poco>(typeof(JTokenToPocoConverter<>))

Просмотреть файл

@ -104,6 +104,26 @@ namespace Microsoft.Azure.WebJobs.Extensions.EventGrid.Tests
_functionOut = null;
}
[Theory]
[InlineData("DirectInvocation.TestString", "stringDataEvent")]
[InlineData("DirectInvocation.TestEventGridEvent", "eventGridEvent")]
public async Task ConsumeDirectInvocation(string functionName, string argument)
{
string value = (string)(typeof(FakeData)).GetField(argument).GetValue(null);
JObject eve = JObject.Parse(value);
var args = new Dictionary<string, object>{
{ "value", value }
};
var expectOut = (string)eve["subject"];
var host = TestHelpers.NewHost<DirectInvocation>();
await host.GetJobHost().CallAsync(functionName, args);
Assert.Equal(_functionOut, expectOut);
_functionOut = null;
}
[Theory]
[InlineData("TriggerParamResolve.TestJObject", "eventGridEvent", @"https://shunsouthcentralus.blob.core.windows.net/debugging/shunBlob.txt")]
[InlineData("TriggerParamResolve.TestString", "stringDataEvent", "goodBye world")]
@ -440,5 +460,18 @@ namespace Microsoft.Azure.WebJobs.Extensions.EventGrid.Tests
}
}
}
public class DirectInvocation
{
public static void TestString([EventGridTrigger] string value)
{
_functionOut = (string)JObject.Parse(value)["subject"];
}
public static void TestEventGridEvent([EventGridTrigger] EventGridEvent value)
{
_functionOut = value.Subject;
}
}
}
}