Skip to content

Commit

Permalink
EventGrid Trigger execution failed in azure portal (Azure#29824)
Browse files Browse the repository at this point in the history
  • Loading branch information
alrod authored Aug 16, 2022
1 parent 4973d43 commit a0cd194
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
# Release History

## 3.3.0-beta.1 (Unreleased)

### Features Added

### Breaking Changes
## 3.2.1 (2022-08-17)

### Bugs Fixed

### Other Changes
- EventGrid Trigger execution failed in azure portal.

## 3.2.0 (2022-04-20)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public void Initialize(ExtensionConfigContext context)
.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 => EventGridEvent.Parse(new BinaryData(jobject.ToString()))) // surface the type to function runtime
.AddConverter<JToken, EventGridEvent[]>(jobject => EventGridEvent.ParseMany(new BinaryData(jobject.ToString())))
.AddConverter<JToken, CloudEvent>(jobject => CloudEvent.Parse(new BinaryData(jobject.ToString())))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks>
<Description>This extension adds bindings for EventGrid</Description>
<Version>3.3.0-beta.1</Version>
<Version>3.2.1</Version>
<!--The ApiCompatVersion is managed automatically and should not generally be modified manually.-->
<ApiCompatVersion>3.2.0</ApiCompatVersion>
<NoWarn>$(NoWarn);AZC0001;CS1591</NoWarn>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,26 @@ public async Task ConsumeCloudEventTest(string functionName)
_functionOut = null;
}

[Theory]
[TestCase("DirectInvocation.TestString", "StringDataEvent")]
[TestCase("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.AreEqual(_functionOut, expectOut);
_functionOut = null;
}

[Theory]
[TestCase("TriggerParamResolve.TestJObject", "EventGridEvent", @"https://shunsouthcentralus.blob.core.windows.net/debugging/shunBlob.txt")]
[TestCase("TriggerParamResolve.TestString", "StringDataEvent", "goodBye world")]
Expand Down Expand Up @@ -878,6 +898,19 @@ public void JObjectEvents([EventGrid(TopicEndpointUri = "eventgridUri", TopicKey
}
}
}

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;
}
}
}

#pragma warning disable SA1402
Expand Down

0 comments on commit a0cd194

Please sign in to comment.