My presentation at the 2016 Miwaukee .NET conference.
Talked about how I leveraged Azure Functions to rapidly prototype a product.
http://www.mkedotnet.com/sessions/azure-functions/
4. SMS Based Survey System
Users can text responses to a question
Users can opt in/out along with preferences
Topics that are time based
Automatic detection of topic
Start with a POC
4
8. 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
10. Function App Folder Structure
● WWWRoot
○ host.json
○ function1
• run.csx
• function.json
• bin
○ function 2
• run.csx
• function.json
• Bin
○ sharedAssemblies
• usefulAssembly.dll
1
11. host.json
● Runtime specific config: Impacts entire function app
● Can set function timeouts, overall behaviors like service bus settings
{
"functionTimeout": "00:10:00"
}
1
13. 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);
}
1
14. 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
1
15. 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
1
16. Function Chaining
● Call a function from another
● Message Queue allows for decoupling
● Allows for semi-pure functional programming
1
17. Where does this leave us?
● Prototype being worked on (for this example)
● People loved it...got sold to a client
1