Skip to content

Instantly share code, notes, and snippets.

Aakash akki-s

Block or report user

Report or block akki-s

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View TimeZoneService.cs
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;;
View FunctionsApp.csproj
<ItemGroup>
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.13" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.0.0" />
</ItemGroup>
View GetTimeZonesHttpTrigger.cs
[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);
View Bootstrap.cs
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 Aug 11, 2018
An azure event grid event for a virtual machine creation
View AzureEventGridEvent.json
{
"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 Aug 11, 2018
An example Azure CLI command to create an Event Grid Subscription, which receives all the events occurring at subscription level
View EventGridSubscription
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 Aug 11, 2018
An Http Triggered Javascript Azure Function to process event grid events. If it's a validation event, send back the validationCode to event grid.
View EventGridHandlerHttpTrigger.js
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')
You can’t perform that action at this time.