public static void Run([TimerTrigger("0 */5 * * * *")] TimerInfo myTimer, ExecutionContext context, ILogger log) { log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}"); var config = new ConfigurationBuilder() .SetBasePath(context.FunctionAppDirectory) .AddJsonFile("local.settings.json") .AddUserSecrets <Configuration>() .Build(); var client = new EventGridPublisherClient( new Uri(config["EventGridUrl"]), new AzureKeyCredential(config["EventGridKey"])); // Add EventGridEvents to a list to publish to the topic EventGridEvent egEvent = new EventGridEvent( "ExampleEventSubject", "Example.EventType", "1.0", "This is the event data"); // Send the event client.SendEvent(egEvent); }
public void SendStockData(StockData stockData) { Console.WriteLine("Sending StockData event"); _eventGridClient.SendEvent(new EventGridEvent( subject: $"{stockData.Symbol}-price-update", eventType: "EventDrivePoc.Event.StockPriceUpdate", dataVersion: "1.0", data: stockData )); }
public static void Run([CosmosDBTrigger( databaseName: "FamilyDatabase", collectionName: "ResultContainer", ConnectionStringSetting = "ConnectionString", LeaseCollectionName = "leases", CreateLeaseCollectionIfNotExists = true)] IReadOnlyList <Document> input, ExecutionContext context, ILogger log) { if (input != null && input.Count > 0) { foreach (var document in input) { var urlCheckResult = JsonConvert.DeserializeObject <UrlCheckResult>(document.ToString()); log.LogInformation($"{urlCheckResult.ExecutedAt} {urlCheckResult.Url} {urlCheckResult.StatusCode}"); if (urlCheckResult.StatusCode.StatusCode == 200) { var config = new ConfigurationBuilder() .SetBasePath(context.FunctionAppDirectory) .AddJsonFile("local.settings.json") .AddUserSecrets <Configuration>() .Build(); var client = new EventGridPublisherClient( new Uri(config["UrlCheckedConfiguration:UrlCheckUrl"]), new AzureKeyCredential(config["UrlCheckedConfiguration:UrlCheckKey"])); // Add EventGridEvents to a list to publish to the topic EventGridEvent egEvent = new EventGridEvent( "ExampleEventSubject", "Example.EventType", "1.0", "This is the event data"); // Send the event client.SendEvent(egEvent); } } } }
public static void Run([TimerTrigger("0 */5 * * * *")] TimerInfo myTimer, ExecutionContext context, ILogger log) { log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}"); var config = new ConfigurationBuilder() .SetBasePath(context.FunctionAppDirectory) .AddJsonFile("local.settings.json") .AddUserSecrets <Configuration>() .Build(); var client = new EventGridPublisherClient( new Uri(config["TriggerUrlCheck:UrlCheckUrl"]), new AzureKeyCredential(config["TriggerUrlCheck:UrlCheckKey"])); client.SendEvent(new EventGridEvent( "ExampleEventSubject", "Example.EventType", "1.0", new DoUrlCheckEventData { Url = "https://plywood-violin.azurewebsites.net/monkey" })); }