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("GenerateNamesTimerFunction")] | |
[return: ServiceBus("newnames-queue", Connection = "ServiceBusConnection")] | |
public static async Task<string> RunTrigger( | |
[TimerTrigger("*/3 * * * * *")]TimerInfo myTimer, | |
[EventHub("names", Connection = "EventHubSendConnection")] IAsyncCollector<string> outputEvents, | |
ILogger log | |
) | |
{ | |
var names = await GetNames(); | |
foreach (var nameRecord in names) | |
{ | |
await outputEvents.AddAsync(nameRecord.ToString()); | |
} | |
return (new JObject( | |
new JProperty("id", Guid.NewGuid().ToString()), | |
new JProperty("data", names.Select(name => new JObject( | |
new JProperty("name", name) | |
))) | |
)).ToString(); | |
} | |
[FunctionName("DequeueGeneratedNames")] | |
[return: Blob("raw-names/{id}.txt", FileAccess.Write, Connection = "AzureWebJobsStorage")] | |
public static string Run( | |
[ServiceBusTrigger("newnames-queue", Connection = "ServiceBusConnection")]NamesGenerationRecord msg, | |
ILogger log) | |
{ | |
return msg.ToString(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment