Skip to content

Instantly share code, notes, and snippets.

View akki-s's full-sized avatar

Aakash akki-s

View GitHub Profile
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;;
<ItemGroup>
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.13" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.0.0" />
</ItemGroup>
[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);
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
{
@akki-s
akki-s / AzureEventGridEvent.json
Last active August 11, 2018 10:24
An azure event grid event for a virtual machine creation
{
"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",
@akki-s
akki-s / EventGridSubscription
Created August 11, 2018 10:08
An example Azure CLI command to create an Event Grid Subscription, which receives all the events occurring at subscription level
az eventgrid event-subscription create --name eg-subscription-test --endpoint https://myhttptriggerfunction.azurewebsites.net/api/f1?code=
@akki-s
akki-s / EventGridHandlerHttpTrigger.js
Last active August 11, 2018 10:05
An Http Triggered Javascript Azure Function to process event grid events. If it's a validation event, send back the validationCode to event grid.
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')