+ All Categories
Home > Technology > Rapid prototyping using azure functions - A walk on the wild side

Rapid prototyping using azure functions - A walk on the wild side

Date post: 16-Apr-2017
Category:
Upload: samrat-saha
View: 80 times
Download: 0 times
Share this document with a friend
19
Presente d By WELCOME MKEDOTNET
Transcript
Page 1: Rapid prototyping using azure functions - A walk on the wild side

Presented By

WELCOME

MKEDOTNET

Page 2: Rapid prototyping using azure functions - A walk on the wild side
Page 3: Rapid prototyping using azure functions - A walk on the wild side

Rapid prototyping using Azure Functions - A Walk on the Wild Side

Samrat Saha08.29.2016

Page 4: Rapid prototyping using azure functions - A walk on the wild side

SMS Based Survey SystemUsers can text responses to a questionUsers can opt in/out along with preferencesTopics that are time basedAutomatic detection of topicStart with a POC

4

Page 5: Rapid prototyping using azure functions - A walk on the wild side

Traditional ApproachWay too many ways to skin this cat - prime concern is infrastructure

5

Page 6: Rapid prototyping using azure functions - A walk on the wild side

Cloud Approach● On-Demand● Horizontal Scaling● Paradigms (Paxos, Consistent Hashing, Redundancies,

SLA’S!)● Azure

6

Page 7: Rapid prototyping using azure functions - A walk on the wild side

7

Page 8: Rapid prototyping using azure functions - A walk on the wild side

Azure Functions● Event driven on demand compute resources● Serverless Architecture● WebJobs SDK as a Service● A function runs in the context of a Function App

8

Page 9: Rapid prototyping using azure functions - A walk on the wild side

Bindings● Triggers: HTTP, Events, Queues● Input: Blob Storage, Table Storage, DocumentDB● Output

9

Page 10: Rapid prototyping using azure functions - A walk on the wild side

Function App Folder Structure● WWWRoot

○ host.json○ function1

• run.csx• function.json• bin

○ function 2• run.csx• function.json• Bin

○ sharedAssemblies• usefulAssembly.dll

10

Page 11: Rapid prototyping using azure functions - A walk on the wild side

host.json● Runtime specific config: Impacts entire function app● Can set function timeouts, overall behaviors like service bus

settings{

"functionTimeout": "00:10:00"

}

11

Page 12: Rapid prototyping using azure functions - A walk on the wild side

function.json{ "bindings": [ { "name": "queueItem", "type": "serviceBusTrigger", "direction": "in", "queueName": "lc_incoming_sms_queue", "connection": "lc_incoming_sms_read_connection", "accessRights": "Listen" }, { "type": "serviceBus", "name": "outputSbMsg", "queueName": "lc_bluemix_results_queue", "connection": "lc_bluemix_results_manage_connection", "accessRights": "Manage", "direction": "out" } ], "disabled": false}

12

Page 13: Rapid prototyping using azure functions - A walk on the wild side

run.csx#r "../sharedAssemblies/LC-SMS-Quote-DomainModel.dll"using System;using System.Threading.Tasks;using LC_SMS_DomainModel;using LC_SMS_DomainModel.AzureLogging;private static TraceWriter _logger;public static void Run(string queueItem, out string outputSbMsg, TraceWriter log){ _logger = log; log.Info($"C# ServiceBus queue trigger function processed message: {queueItem}"); AzureLogger.InfoCallback = new AzureLogger.InfoDelegate(InfoDelegate); LCSMSDomainModel domainModel = new LCSMSDomainModel(); domainModel.Init(); String response = domainModel.HandleIncomingSMS(queueItem); outputSbMsg = response;}public static void VerboseDelegate(String message, String source){ _logger.Verbose(message);}public static void InfoDelegate(String message, String source=null){ _logger.Info(message);}

13

Page 14: Rapid prototyping using azure functions - A walk on the wild side

Leveraging External Assemblies● Some namespaces like System automatically imported● Framework assemblies (automatically available through

Azure Functions Hosting Environment)#r “System.Web.Http"

● bin folder relative to function#r “functionSpecificUsefuldll.dll"

● Shared assemblies in under webroot, accessible by relative path

#r "../sharedAssemblies/LC-SMS-Quote-DomainModel.dll"● Inside assembly to access config:

String storageAccountId = Environment.GetEnvironmentVariable(CONFIG_STORAGE_ACCOUNT,EnvironmentVariableTarget.Process);

● Use Project.Json for NuGet

14

Page 15: Rapid prototyping using azure functions - A walk on the wild side

Scaling● App Service Plan: Dedicated VM, leverage under utilized

resources, good for long running● Dynamic Service Plan: Function app instance...more

instances can be added dynamically. Best use for intermittent/ short running

● Parallel Execution: Single threaded function runtime-> Scale to multiple

15

Page 16: Rapid prototyping using azure functions - A walk on the wild side

Function Chaining● Call a function from another● Message Queue allows for decoupling● Allows for semi-pure functional programming

16

Page 17: Rapid prototyping using azure functions - A walk on the wild side

Where does this leave us?● Prototype being worked on (for this example)● People loved it...got sold to a client

17

Page 18: Rapid prototyping using azure functions - A walk on the wild side

18

Page 19: Rapid prototyping using azure functions - A walk on the wild side

ThanksCentareLC

19


Recommended