This file contains 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
[FunctionName("RegistOrder")] | |
public static async Task<HttpResponseMessage> RegistOrder( | |
[HttpTrigger(AuthorizationLevel.Function, "post", Route = "order")]HttpRequestMessage request | |
,[OrchestrationClient]DurableOrchestrationClientBase client) | |
{ | |
var input = await request.Content.ReadAsStringAsync(); | |
var instanceId = await client.StartNewAsync("OrderRegistOrchestrator", int.Parse(input)); | |
return client.CreateCheckStatusResponse(request, instanceId); | |
} |
This file contains 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
[FunctionName("OrderRegistOrchestrator")] | |
public static async Task OrderRegistOrchestrator( | |
[OrchestrationTrigger]DurableOrchestrationContext ctx) | |
{ | |
int orderNo = ctx.GetInput<int>(); | |
// Order情報をつけとって | |
Order order = await ctx.CallActivityAsync<Order>("GetOrder", orderNo); |
This file contains 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
[FunctionName("GetOrder")] | |
public static async Task<Order> GetOrderActivity([ActivityTrigger]int input) | |
{ | |
var client = new HttpClient(); | |
var json = await client.GetStringAsync($"https://hogehoge.com/order/{input}"); | |
return JsonConvert.DeserializeObject<Order>(json); | |
} | |
[FunctionName("SendOrder")] | |
public static async Task SendOrderActivity([ActivityTrigger]Order input) |
This file contains 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
public static class ConfigurationManagerRequired | |
{ | |
static ConfigurationManagerRequired() | |
{ | |
AppSettings = new AppSettingsRequired(); | |
} | |
public static AppSettingsRequired AppSettings { get; } |
This file contains 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
[FunctionName("OrderOrchestrator")] | |
public static async Task Order([OrchestrationTrigger]DurableOrchestrationContextBase context) | |
{ | |
var order = context.GetInput<OrderModel>(); | |
await context.CallActivityAsync("InsertToRepository" , order); | |
while (true) | |
{ | |
try |
This file contains 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
[FunctionName("HookRecieve")] | |
public static async Task<HttpResponseMessage> Run( | |
[HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)]HttpRequestMessage req | |
, [Table("KeySaveTable")] CloudTable table | |
, [OrchestrationClient] DurableOrchestrationClient client | |
, TraceWriter log) | |
{ | |
var json = await req.Content.ReadAsStringAsync(); | |
var result = JsonConvert.DeserializeObject<WebHookResult>(json); | |
var query = new TableQuery<TableEntity>() |
This file contains 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
[FunctionName(nameof(SaveRequestKeyActivity))] | |
public static async Task SaveRequestKeyActivity( | |
[ActivityTrigger] DurableActivityContext context, | |
[Table("KeySaveTable")] CloudTable table | |
) | |
{ | |
var key = context.GetInput<string>(); | |
var insertOperation = TableOperation.Insert(new TableEntity(key, context.InstanceId)); | |
await table.ExecuteAsync(insertOperation); | |
} |
This file contains 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
[FunctionName(nameof(HookApiRequestActivity))] | |
public static async Task<string> HookApiRequestActivity( | |
[ActivityTrigger] int requestValue | |
) | |
{ | |
var url = $"{ConfigurationManager.AppSettings["HookUrl"]}?Value={requestValue}"; | |
ServicePointManager.DefaultConnectionLimit = 100; | |
using (var client = new HttpClient()) | |
{ | |
var result = await client.GetStringAsync(url); |
This file contains 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
[FunctionName(nameof(WebHookOrchestrator))] | |
public static async Task<ResultModel> WebHookOrchestrator( | |
[OrchestrationTrigger]DurableOrchestrationContext context | |
) | |
{ | |
var requestVaue = context.GetInput<int>(); | |
var hookKey = await context.CallActivityAsync<string>(nameof(HookApiRequestActivity), requestVaue); | |
await context.CallActivityAsync(nameof(SaveRequestKeyActivity), hookKey); | |
var result = await context.WaitForExternalEvent<ResultModel>(HookWaitEventName); | |
return result; |
This file contains 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
public Task<IListener> CreateListenerAsync(ListenerFactoryContext context) | |
{ | |
_configuration.AddConfigExecutor(context.Descriptor.ShortName, context.Executor); | |
return Task.FromResult((IListener) new InjectConfigurationTriggerListener()); | |
} |