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 class TimeZoneService : ITimeZoneService | |
{ | |
private const string ContainerName = "azfnv2demo"; | |
private const string FileName = "timezones.json"; | |
private readonly IAzureBlobStorageHelper _azureBlobStorageHelper; | |
public TimeZoneService(IAzureBlobStorageHelper azureBlobStorageHelper) | |
{ | |
_azureBlobStorageHelper = azureBlobStorageHelper;; |
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
<ItemGroup> | |
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.13" /> | |
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.0.0" /> | |
</ItemGroup> |
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("GetTimeZones")] | |
public static async Task<IActionResult> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "timezones")]HttpRequest req, ILogger log) | |
{ | |
var serviceProvider = Bootstrap.ConfigureServices(); | |
log.LogInformation("GET TIMEZONES"); | |
var timeZoneService = ServiceProvider.GetService<ITimeZoneService>(); | |
var timeZones = await timeZoneService.GetTimeZones().ConfigureAwait(false); |
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
using Azure.Functions.v2.DI.Helpers; | |
using Azure.Functions.v2.DI.Services; | |
using Microsoft.Extensions.DependencyInjection; | |
using System; | |
using Microsoft.Extensions.Logging; | |
namespace Azure.Functions.v2.DI.FunctionApp | |
{ | |
public static class Bootstrap | |
{ |
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
{ | |
"subject": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourcegroups/resource-group/providers/Microsoft.Compute/virtualMachines/vmName", | |
"eventType": "Microsoft.Resources.ResourceWriteSuccess", | |
"eventTime": "2018-08-05T14:48:32.945Z", | |
"id": "0605b293-e06e-48ac-a16d-9322fe8e24dd", | |
"data": | |
{ | |
"authorization": | |
{ | |
"scope": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourcegroups/resource-group/providers/Microsoft.Compute/virtualMachines/vmName", |
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
az eventgrid event-subscription create --name eg-subscription-test --endpoint https://myhttptriggerfunction.azurewebsites.net/api/f1?code= |
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
module.exports = function (context, req) { | |
for (var events in req.body) { | |
var body = req.body[events]; | |
if (body.data && body.eventType == "Microsoft.EventGrid.SubscriptionValidationEvent") { | |
context.log("event grid validation event, validation code: " + body.data.validationCode); | |
//validate header | |
if(req.headers['aeg-event-type'] && req.headers['aeg-event-type'] == 'SubscriptionValidation') |