Introduction to serverless compute with Azure Functions. This is an introductory-level session on serverless compute with Azure Functions and how they can be used to process events with a serverless code architecture.
2. Microsoft Azure
About me
Callon Campbell
Systems Architect / Developer. 19 years of
experience developing desktop, mobile and web
enterprise applications using .NET Framework, SQL
Server and Azure technologies.
Co-creator of ReflectInsight, a.NET logging
framework and a real-time Live Log Viewer.
2
Email: CallonCampbell@Outlook.com Twitter: @Flying_Maverick
Blog: http://TheFlyingMaverick.com LinkedIn: LinkedIn.com/in/calloncampbell
Website: http://ReflectInsight.com Slideshare: https://www.slideshare.net/calloncampbell
4. Microsoft Azure
What is Azure Functions?
• Azure Functions are a serverless event driven compute on
demand experience
• Think of Azure Functions as…
• C#, Node.js and Java
• Visual Studio, VS Code and CLI tooling
9. Microsoft Azure
What can I do with Azure Functions?
•Azure Functions are great for processing data,
integrating systems, working with IoT, simple API’s
and microservices
•Azure Functions provide templates for a number of
key scenarios
•Azure Functions supports
• Triggers - a way to start execution
• Bindings - a way to simplify code for input and output of
data
10
10. Microsoft Azure
Integrations
• Azure Functions can be
triggered by virtually any
event in Azure, other 3rd
party services or even from
on-premise systems
• These services can trigger
your function (startup) or
serve as input and output
for your code
11
Supported Integrations
• CosmosDB
• Event Hubs
• Mobile Apps (tables)
• Notification Hubs
• Service Bus (queues, topics)
• Storage (blob, queues, tables)
• GitHub (webhooks)
• Twilio (SMS messages)
• On-premises (using Service Bus)
21. Microsoft Azure
Serverless mobile backends
A mobile backend can be just a set of HTTP APIs that
are called from a mobile client using the WebHook
URL.
34
25. Microsoft Azure
Summary
• With Azure Functions, the focus is on the code and not
managing the infrastructure.
• When used as the serverless compute component of a
serverless architecture, you have the following benefits:
• Reduced time to market
• Lower total cost of ownership
• Pay per execution
38
26. Microsoft Azure
Azure serverless compute
•It’s now becoming easier than ever to create small,
targeted microservice architecture using a variety of
services
•Azure provides many services that can help you
achieve a low-friction, high-throughput and low-cost
solution
•Azure Functions, Logic Apps, Event Grid are just a
few in the serverless architecture family
39
29. Microsoft Azure
What’s next?
•Try Azure Functions for free:
https://azure.microsoft.com/en-us/try/app-service/
•Blog:https://blogs.msdn.microsoft.com/appservicete
am/tag/azure-functions/
•Twitter: @AzureFunctions
•Learn more at Microsoft Virtual Academy and
Channel 9
42
30. Microsoft Azure
References
• https://azure.microsoft.com/en-us/services/functions/
• https://functions.azure.com/
• https://portal.azure.com/
• https://docs.microsoft.com/en-us/azure/azure-functions/
• https://azure.microsoft.com/en-us/pricing/details/functions/
• Azure Functions in Practice
• Azure - Serverless Architecture with Azure Functions
• Visual Studio Tools for Azure Functions Preview
• Azure Storage Explorer
43
Notas del editor
Overview – Serverless and what are Azure Functions
Dev tooling – Tools along with deployment and monitoring capabilities
Azure Functions is an event driven, compute-on-demand experience. Basically just provide your code and Azure will take care of the rest…meaning that when an event happens, Azure will automatically take care of everything to run that code at scale.
Azure functions can runs EXE’s or call into DLL’s
Azure Functions are built on top of Azure App Service and WebJobs SDK -> this means that Azure Functions gets all the benefits of using Azure App Service
Key take away is that Azure Functions gets all the benefits of using Azure App Service.
So what do I mean by serverless scale.
Well back in the old days and propbably still today we have people building monolith applications…which don’t scale.
So people started to breakdown their applications into microservices and maybe even use Service Fabric.
With Azure Functions we take it one step further and can create nano services.
First and foremost its an abstractions of servers:
Don’t need to worry about optimizing which OS to run on, or patching, etc
Don’t need to worry about optimize server utilization and scaling up and down for demand
Event driven process
Tell Azure how or when to run your code (is it based on a schedule, or when a new customer is added to salesforce, or when items are added to a queue, a table or storage, etc)
Micro build
You’re only charged for your usage
Dynamically and elastically scale to meet demand.
Allows you as the developer to focus on your business logic. Everything else is taken cared for you.
This drastically increases time to market.
3 key points:
1. Reduce time to market
2. Focus on innovating on new features
3. Enables you to be more competitive
Any number of input and output bindings, but only have a single trigger.
With runtime v2 you can now host on Windows or Linux (in preview)
Supports remote debugging for C# only.
Executing locally is handled by the Azure Functions CLI
When you’re ready it provides the capability to publish to Azure.
https://portal.azure.com/
I’ll now show you how to get started creating and running a simple HttpTrigger function from the Azure Portal.
https://portal.azure.com/
I’ll now show you how to get started creating and running a simple HttpTrigger function from the Azure Portal.
Use the QuickStart process to create a premade function or using the left side navigation, create your own custom function.
There are a number of templates available for different languages including some prebuilt samples. Looking at these samples and experiment functions is a great way to see what you can do.
When you’re function is ready, save and run it immediately in the portal and see the output in the logs.
You can also test your functions from the right navigation pane.
File -> New Project, look under Cloud and then select “Azure Functions (Preview)”.
Storage account connection should be “AzureWebJobsStorage”. You will then add your connection string to that keys value in the AppSettings.
AppSettings are shared across functions.
Using the Azure Storage Explorer, I can get my connection string for the storage account. Get Primary Connection String and add to AppSettings to key “AzureWebJobsStorage”.
I can also insert some sample test data to be consumed by my function.
Adjust timing polling.
Open up Host.json and using intellisence, add “queues” : {“maxPollingInterval”: 1000} where this value is in milliseconds.
For example, you could execute code that runs every 15 minutes and cleans up a database table based on custom business logic.
For example, you could execute a function that reads newly discovered log files in an Azure Blob Storage container. The data can then be transformed into a row in an Azure SQL Database table, or DocumentDB or perhaps feed it into another service.
C# Azure Function for reacting to Azure Insights Events
For example, when a file is saved in OneDrive, this triggers a function that uses the Microsoft Graph API to modify the spreadsheet, creating additional charts and calculated data.
The app calls functions using the WebHook URL, saving user data and deciding what data to display. Or, you can do simple customizations, such as changing an ad based on user profile information.
Node.js Azure Function for generating SAS tokens C# Azure Function for generating SAS tokens
For example, a mobile application could capture an image, then call an Azure Function to get an access token for uploading to blob storage. A second Azure Function is triggered by the blob upload and resizes the image to be mobile-friendly.
For example, IoT devices send messages to Azure Stream Analytics, which then calls an Azure Function to transform the message. This function processes the data and creates a new record in an Azure SQL Database.
For example, you can create an Azure Function that processes a message using Cortana Analytics and call this function using the Microsoft Bot Framework.