Created
December 20, 2017 04:00
-
-
Save kareem613/a27a7fce39600e63d03bd262963b00c3 to your computer and use it in GitHub Desktop.
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
using Microsoft.Azure.WebJobs; | |
using Microsoft.Azure.WebJobs.Extensions.Http; | |
using Microsoft.Azure.WebJobs.Host; | |
using System; | |
using System.Net.Http; | |
using System.Net.Http.Headers; | |
using System.Threading.Tasks; | |
namespace AzureFunctionApp | |
{ | |
public static class DoubleSerializationBug | |
{ | |
[FunctionName("BugTrigger")] | |
public static async Task<HttpResponseMessage> HttpStarter( | |
[HttpTrigger(AuthorizationLevel.Anonymous, methods: "post", Route = "bugs/trigger")] HttpRequestMessage req, | |
[OrchestrationClient] DurableOrchestrationClient starter, | |
TraceWriter log) | |
{ | |
// Function input comes from the request content. ex. {"propery":"somevalue"} | |
dynamic eventData = await req.Content.ReadAsAsync<dynamic>(); | |
var paramData = new InputBody() { Name = eventData.property }; | |
string instanceId = await starter.StartNewAsync("BugSample", paramData); | |
log.Info($"Started orchestration with ID = '{instanceId}'."); | |
var res = starter.CreateCheckStatusResponse(req, instanceId); | |
res.Headers.RetryAfter = new RetryConditionHeaderValue(TimeSpan.FromSeconds(10)); | |
return res; | |
} | |
[FunctionName("BugSample")] | |
public static async Task BugSample( | |
[OrchestrationTrigger] DurableOrchestrationContext context, TraceWriter log) | |
{ | |
var input = context.GetInput<InputBody>(); | |
var resultSub = await context.CallSubOrchestratorAsync<string>("SubOrchestrationFunction", input); | |
} | |
[FunctionName("SubOrchestrationFunction")] | |
public static async Task SubOrchestrationFunction( | |
[OrchestrationTrigger] DurableOrchestrationContext context, TraceWriter log) | |
{ | |
log.Warning("Attempting to deserialize input in suborchestration"); | |
var input = context.GetInput<InputBody>(); | |
} | |
public class InputBody | |
{ | |
public string Name { get; set; } | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment