SlideShare une entreprise Scribd logo
1  sur  31
Télécharger pour lire hors ligne
Working with data
using Azure
Functions
Liam Moat
Steph Locke
What we’re here to talk
about
• What are Azure Functions?
• How to position serverless for your workloads
• Using Azure Functions for data processing
Steph & Liam
Steph Locke
Tw: @theStephLocke
Li: stephanielocke
GH: stephlocke
Liam Moat
Li: liammoatcom
GH: liammoat
Azure Functions
Level
of
abstraction
Focus on business logic
Physical server
Virtual machine
PaaS
Containerization
Serverless
No infrastructure
management
Developers can just focus on
their code—without needing
to worry about provisioning
and managing infrastructure
Instant, event-
driven scalability
Application components
react to events and triggers
in near real-time with
virtually unlimited scalability
Pay-per-use
Only pay for what you use:
billing is typically calculated
on the number of function
calls, code execution time, and
memory used*
*Supporting services, like storage and networking, may be charged separately.
Functions-as-a-Service programming model use functions to achieve true serverless compute
Single
responsibility
Functions are single-
purposed, reusable pieces of
code that process an input
and return a result
Short-lived
Functions don’t stick around
when finished executing,
freeing up resources
for further executions
Stateless
Functions don’t hold any
persistent state and
don’t rely on the state of any
other processes
Event-driven
and scalable
Functions respond to
predefined events, and are
instantly replicated
as many times as needed
An event-based, serverless compute experience that accelerates app development
Integrated
programming
model
Use built-in triggers and
bindings to define when a
function is invoked and to what
data it connects
End-to-end
development
experience
Take advantage of a complete,
end-to-end development
experience with Functions—from
building and debugging
locally on major platforms like
Windows, macOS, and Linux
to deploying and monitoring in
the cloud
Hosting
options
flexibility
Choose the deployment model
that better fits your business
needs without compromising
development experience
Fully
managed and
cost-effective
Automated and flexible scaling
based on your workload
volume, keeping the focus on
adding value instead of
managing infrastructure
Integrated programming model
Azure Functions features input/output bindings
which provide a means of pulling data or
pushing data to other services. These bindings
work for both Microsoft and third-party services
without the need to hard-code integrations.
Trigger
Input binding
Output binding
Trigger object
Your code
Input object
Output object
The “Old” Way - Pseudocode
func Run()
{
var connectionString = CloudConfigurationManager.GetSetting("storage:connection")
var storageAccount = CloudStorageAccount.Parse(connectionString)
var eventHubClient = EventHubClient.CreateFromConnectionString(eventHubConnection)
func Poll()
{
var queueClient = storageAccount.CreateCloudQueueClient()
var queue = queueClient.GetQueueReference("myqueue-items")
queue.CreateIfNotExists()
var msg = queue.PeekMessage().AsString
var tableClient = storageAccount.CreateCloudTableClient()
var table = tableClient.GetTableReference("people")
table.CreateIfNotExists()
var customer = table.Execute(TableOperation.Retrieve<Customer>(“Customer”, msg))
// do something with customer - business logic goes here.
eventHubClient.Send(new EventData(...))
queue.DeleteMessage(msg);
Sleep(10 seconds)
Poll()
}
Poll()
}
Triggers - Pseudocode
func Run([QueueTrigger("myqueue-items")] string msg)
{
var connectionString = CloudConfigurationManager.GetSetting("storage:connection")
var storageAccount = CloudStorageAccount.Parse(connectionString)
var eventHubClient = EventHubClient.CreateFromConnectionString(eventHubConnection)
var tableClient = storageAccount.CreateCloudTableClient()
var table = tableClient.GetTableReference("people")
table.CreateIfNotExists()
var customer = table.Execute(TableOperation.Retrieve<Customer>("Customer", msg))
// do something with customer - business logic goes here.
eventHubClient.Send(new EventData(...))
}
Inputs - Pseudocode
func Run([QueueTrigger("myqueue-items")] string myQueueItem
[Table("people", "my-partition", "{queueTrigger}")] Customer customer)
{
var eventHubClient = EventHubClient.CreateFromConnectionString(eventHubConnection)
// do something with customer - business logic goes here.
eventHubClient.Send(new EventData(...))
}
Outputs - Pseudocode
[return: EventHub("event-hub", Connection = "EventHubConnection")]
Func EventData Run([QueueTrigger("myqueue-items")] string myQueueItem
[Table("MyTable", "MyPartition", "{queueTrigger}")] Customer customer)
{
// do something with customer - business logic goes here.
return new EventData(...)
}
Streamlining
connections and
improving security
Use Managed Identities for downstream
connections and for clients that invoke
Functions
Leverage Azure Key Vault for services
without support for MI
Managed Identities and Key Vault secrets
allows others to manage access and
minimises risk of leaked credentials
Use Azure Functions v4 for MI support
Managed Identities + Infrastructure as Code FTW
Step 1:
Assign the Managed Identity
access to resources
Step 2:
Add simplified values to app
settings
Step 3:
Use simple connection
references in Functions
DEMO: Creating an Azure Function project
IaC (bicep), VS Code (Azure Functions and bicep extensions), Azure
Function Core Tools, Github Copilot
Working with data
Automation of scheduled tasks
S C E N A R I O E X A M P L E
Financial services
A customer database is analyzed
for duplicate entries every
15 minutes, to avoid multiple
communications being sent out
to same customers
A function cleans a database
every 15 minutes…
…deduplicating entries
based on business logic
Handling data with a schedule
Timer.cs
[FunctionName("TimerTriggerCSharp")]
public static void Run([TimerTrigger("0 */5 * * * *")]TimerInfo myTimer, ILogger log)
{
// Business logic goes here…
}
Use NCRONTAB specifications for schedules
Schedules can be managed in appsettings to put all schedules in a single location
Use inputs and outputs to handle whatever you need to do
Real-time stream processing
S C E N A R I O E X A M P L E
ISV
Huge amounts of telemetry
data is collected from a massive
cloud app. That data is
processed in near real-time and
stored in a DB for use
in an analytics dashboard
App or device
producing data
Event Hubs ingests
telemetry data A function processes
the data…
…and sends it to
Cosmos DB
Data used for
dashboard
visualizations
Handling events
Queue.cs
public static class QueueFunctions
{
[FunctionName("QueueTrigger")]
public static void QueueTrigger(
[QueueTrigger("items")] string myQueueItem,
ILogger log)
{
// Business logic goes here…
}
}
Use a trigger that listens to an event publisher
Process messages with a schema to improve quality
Choose to process single messages or micro-batches
Handling data on change
S C E N A R I O E X A M P L E
Financial Services
Colleagues use mobile banking
to reimburse each other for
lunch: the person who paid for
lunch requests payment through
his mobile app, triggering a
notification on his colleagues’
phones.
Handling data when there’s changes
CosmosDB.cs
[FunctionName("CosmosTrigger")]
public static void Run([CosmosDBTrigger(
databaseName: "CorpDB",
containerName: "CorpDB",
Connection = "CorpDB",
LeaseContainerName = "leases")]IReadOnlyList<Person> documents,
ILogger log)
{
// Business logic goes here…
}
Use a trigger for a source that has CDC – primarily Cosmos DB and Azure SQL
Process messages with a schema to improve quality
Use inputs to get additional record sets to support processing
Handling data on request
S C E N A R I O E X A M P L E
Professional Services
A SaaS solution provides
extensibility through webhooks,
which can be implemented
through Functions, to automate
certain workflows.
Handling data when requested
HTTP.cs
[FunctionName("HttpTriggerCSharp")]
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)]
HttpRequest req, ILogger log)
{
// Business logic goes here…
}
Use HTTP triggers to create APIs or webhook driven activities
Use OpenAPI decorators to add documentation to your functions
Use Managed Identity on resources that connect or do pass through auth where
possible
?
Workflows and orchestration
with Durable Functions
P A T T E R N S / U S E C A S E S
Durable Functions is an
extension of Azure Functions
that lets you write stateful
functions in a serverless
compute environment
Manageable sequencing +
error handling/compensation
Fanning out and fanning in External events correlation
Flexible automated long-running
process monitoring
Start
Get status
Http-based async long-
running APIs Human interaction
Handling data with multiple steps
Durable.cs
[FunctionName("Chaining")]
public static async Task<object> Run(
[OrchestrationTrigger] IDurableOrchestrationContext context)
{
var x = await context.CallActivityAsync<object>("F1", null);
await context.CallActivityAsync<object>("F2", x);
}
Orchestrate complex or stateful data flows using Durable Functions
Use for different cases like aggregating, fanning out, human in the loop, or
chaining functions
DEMO: Creating different Azure Functions
VS Code (Azure Functions & Azurite extensions), Azure Functions Core
Tools, Github Copilot, Event Hub, Azure SQL, CosmosDB
Closing
What we talked about
• What are Azure Functions?
• How to position serverless for your workloads
• Using Azure Functions for data processing
Try it yourself
Learn with our Cloud Skills
Challenge
aka.ms/sqlbits-dwf
Check out our repo to see
things in detail
aka.ms/sqlbits-dwf-demo
Give it ago with free Azure
resources
Free Services

Contenu connexe

Similaire à Working with data using Azure Functions.pdf

Apache Samza 1.0 - What's New, What's Next
Apache Samza 1.0 - What's New, What's NextApache Samza 1.0 - What's New, What's Next
Apache Samza 1.0 - What's New, What's NextPrateek Maheshwari
 
Serverless in-action
Serverless in-actionServerless in-action
Serverless in-actionAssaf Gannon
 
Develop in ludicrous mode with azure serverless
Develop in ludicrous mode with azure serverlessDevelop in ludicrous mode with azure serverless
Develop in ludicrous mode with azure serverlessLalit Kale
 
Fabric - Realtime stream processing framework
Fabric - Realtime stream processing frameworkFabric - Realtime stream processing framework
Fabric - Realtime stream processing frameworkShashank Gautam
 
Azure Durable Functions (2019-03-30)
Azure Durable Functions (2019-03-30) Azure Durable Functions (2019-03-30)
Azure Durable Functions (2019-03-30) Paco de la Cruz
 
Azure Durable Functions (2018-06-13)
Azure Durable Functions (2018-06-13)Azure Durable Functions (2018-06-13)
Azure Durable Functions (2018-06-13)Paco de la Cruz
 
Logisland "Event Mining at scale"
Logisland "Event Mining at scale"Logisland "Event Mining at scale"
Logisland "Event Mining at scale"Thomas Bailet
 
Observability foundations in dynamically evolving architectures
Observability foundations in dynamically evolving architecturesObservability foundations in dynamically evolving architectures
Observability foundations in dynamically evolving architecturesBoyan Dimitrov
 
AWS Step Functions을 활용한 서버리스 앱 오케스트레이션
AWS Step Functions을 활용한 서버리스 앱 오케스트레이션AWS Step Functions을 활용한 서버리스 앱 오케스트레이션
AWS Step Functions을 활용한 서버리스 앱 오케스트레이션Amazon Web Services Korea
 
Stephane Lapointe, Frank Boucher & Alexandre Brisebois: Les micro-services et...
Stephane Lapointe, Frank Boucher & Alexandre Brisebois: Les micro-services et...Stephane Lapointe, Frank Boucher & Alexandre Brisebois: Les micro-services et...
Stephane Lapointe, Frank Boucher & Alexandre Brisebois: Les micro-services et...MSDEVMTL
 
FMK2019 being an optimist in a pessimistic world by vincenzo menanno
FMK2019 being an optimist in a pessimistic world by vincenzo menannoFMK2019 being an optimist in a pessimistic world by vincenzo menanno
FMK2019 being an optimist in a pessimistic world by vincenzo menannoVerein FM Konferenz
 
The Art of The Event Streaming Application: Streams, Stream Processors and Sc...
The Art of The Event Streaming Application: Streams, Stream Processors and Sc...The Art of The Event Streaming Application: Streams, Stream Processors and Sc...
The Art of The Event Streaming Application: Streams, Stream Processors and Sc...confluent
 
Kakfa summit london 2019 - the art of the event-streaming app
Kakfa summit london 2019 - the art of the event-streaming appKakfa summit london 2019 - the art of the event-streaming app
Kakfa summit london 2019 - the art of the event-streaming appNeil Avery
 
CiklumJavaSat_15112011:Alex Kruk VMForce
CiklumJavaSat_15112011:Alex Kruk VMForceCiklumJavaSat_15112011:Alex Kruk VMForce
CiklumJavaSat_15112011:Alex Kruk VMForceCiklum Ukraine
 
Track 4 Session 2_MAD03 容器技術和 AWS Lambda 讓您專注「應用優先」.pptx
Track 4 Session 2_MAD03 容器技術和 AWS Lambda 讓您專注「應用優先」.pptxTrack 4 Session 2_MAD03 容器技術和 AWS Lambda 讓您專注「應用優先」.pptx
Track 4 Session 2_MAD03 容器技術和 AWS Lambda 讓您專注「應用優先」.pptxAmazon Web Services
 
Couchbase@live person meetup july 22nd
Couchbase@live person meetup   july 22ndCouchbase@live person meetup   july 22nd
Couchbase@live person meetup july 22ndIdo Shilon
 
O365Con19 - Developing Timerjob and Eventhandler Equivalents - Adis Jugo
O365Con19 - Developing Timerjob and Eventhandler Equivalents - Adis JugoO365Con19 - Developing Timerjob and Eventhandler Equivalents - Adis Jugo
O365Con19 - Developing Timerjob and Eventhandler Equivalents - Adis JugoNCCOMMS
 
Azure Durable Functions (2019-04-27)
Azure Durable Functions (2019-04-27)Azure Durable Functions (2019-04-27)
Azure Durable Functions (2019-04-27)Paco de la Cruz
 

Similaire à Working with data using Azure Functions.pdf (20)

Apache Samza 1.0 - What's New, What's Next
Apache Samza 1.0 - What's New, What's NextApache Samza 1.0 - What's New, What's Next
Apache Samza 1.0 - What's New, What's Next
 
Serverless in-action
Serverless in-actionServerless in-action
Serverless in-action
 
Develop in ludicrous mode with azure serverless
Develop in ludicrous mode with azure serverlessDevelop in ludicrous mode with azure serverless
Develop in ludicrous mode with azure serverless
 
Fabric - Realtime stream processing framework
Fabric - Realtime stream processing frameworkFabric - Realtime stream processing framework
Fabric - Realtime stream processing framework
 
Azure Durable Functions (2019-03-30)
Azure Durable Functions (2019-03-30) Azure Durable Functions (2019-03-30)
Azure Durable Functions (2019-03-30)
 
Azure Durable Functions (2018-06-13)
Azure Durable Functions (2018-06-13)Azure Durable Functions (2018-06-13)
Azure Durable Functions (2018-06-13)
 
Logisland "Event Mining at scale"
Logisland "Event Mining at scale"Logisland "Event Mining at scale"
Logisland "Event Mining at scale"
 
Tdd,Ioc
Tdd,IocTdd,Ioc
Tdd,Ioc
 
Observability foundations in dynamically evolving architectures
Observability foundations in dynamically evolving architecturesObservability foundations in dynamically evolving architectures
Observability foundations in dynamically evolving architectures
 
AWS Step Functions을 활용한 서버리스 앱 오케스트레이션
AWS Step Functions을 활용한 서버리스 앱 오케스트레이션AWS Step Functions을 활용한 서버리스 앱 오케스트레이션
AWS Step Functions을 활용한 서버리스 앱 오케스트레이션
 
Stephane Lapointe, Frank Boucher & Alexandre Brisebois: Les micro-services et...
Stephane Lapointe, Frank Boucher & Alexandre Brisebois: Les micro-services et...Stephane Lapointe, Frank Boucher & Alexandre Brisebois: Les micro-services et...
Stephane Lapointe, Frank Boucher & Alexandre Brisebois: Les micro-services et...
 
FMK2019 being an optimist in a pessimistic world by vincenzo menanno
FMK2019 being an optimist in a pessimistic world by vincenzo menannoFMK2019 being an optimist in a pessimistic world by vincenzo menanno
FMK2019 being an optimist in a pessimistic world by vincenzo menanno
 
CQRS and Event Sourcing
CQRS and Event SourcingCQRS and Event Sourcing
CQRS and Event Sourcing
 
The Art of The Event Streaming Application: Streams, Stream Processors and Sc...
The Art of The Event Streaming Application: Streams, Stream Processors and Sc...The Art of The Event Streaming Application: Streams, Stream Processors and Sc...
The Art of The Event Streaming Application: Streams, Stream Processors and Sc...
 
Kakfa summit london 2019 - the art of the event-streaming app
Kakfa summit london 2019 - the art of the event-streaming appKakfa summit london 2019 - the art of the event-streaming app
Kakfa summit london 2019 - the art of the event-streaming app
 
CiklumJavaSat_15112011:Alex Kruk VMForce
CiklumJavaSat_15112011:Alex Kruk VMForceCiklumJavaSat_15112011:Alex Kruk VMForce
CiklumJavaSat_15112011:Alex Kruk VMForce
 
Track 4 Session 2_MAD03 容器技術和 AWS Lambda 讓您專注「應用優先」.pptx
Track 4 Session 2_MAD03 容器技術和 AWS Lambda 讓您專注「應用優先」.pptxTrack 4 Session 2_MAD03 容器技術和 AWS Lambda 讓您專注「應用優先」.pptx
Track 4 Session 2_MAD03 容器技術和 AWS Lambda 讓您專注「應用優先」.pptx
 
Couchbase@live person meetup july 22nd
Couchbase@live person meetup   july 22ndCouchbase@live person meetup   july 22nd
Couchbase@live person meetup july 22nd
 
O365Con19 - Developing Timerjob and Eventhandler Equivalents - Adis Jugo
O365Con19 - Developing Timerjob and Eventhandler Equivalents - Adis JugoO365Con19 - Developing Timerjob and Eventhandler Equivalents - Adis Jugo
O365Con19 - Developing Timerjob and Eventhandler Equivalents - Adis Jugo
 
Azure Durable Functions (2019-04-27)
Azure Durable Functions (2019-04-27)Azure Durable Functions (2019-04-27)
Azure Durable Functions (2019-04-27)
 

Plus de Stephanie Locke

Let's banish "it works on my machine"
Let's banish "it works on my machine"Let's banish "it works on my machine"
Let's banish "it works on my machine"Stephanie Locke
 
How to build brilliant managers.pdf
How to build brilliant managers.pdfHow to build brilliant managers.pdf
How to build brilliant managers.pdfStephanie Locke
 
The Microsoft Well Architected Framework For Data Analytics
The Microsoft Well Architected Framework For Data AnalyticsThe Microsoft Well Architected Framework For Data Analytics
The Microsoft Well Architected Framework For Data AnalyticsStephanie Locke
 
Sustainable manufacturing with AI
Sustainable manufacturing with AISustainable manufacturing with AI
Sustainable manufacturing with AIStephanie Locke
 
Wrangling data like a boss
Wrangling data like a bossWrangling data like a boss
Wrangling data like a bossStephanie Locke
 
Digitalisation from the back office to the factory floor
Digitalisation from the back office to the factory floorDigitalisation from the back office to the factory floor
Digitalisation from the back office to the factory floorStephanie Locke
 
The fundamentals of regression
The fundamentals of regressionThe fundamentals of regression
The fundamentals of regressionStephanie Locke
 
Practical AI & data science ethics
Practical AI & data science ethicsPractical AI & data science ethics
Practical AI & data science ethicsStephanie Locke
 
Help There’s Too Many [Something]Ops!
Help There’s Too Many [Something]Ops!Help There’s Too Many [Something]Ops!
Help There’s Too Many [Something]Ops!Stephanie Locke
 
Reproducible machine learning
Reproducible machine learningReproducible machine learning
Reproducible machine learningStephanie Locke
 
AI monitoring in the workplace
AI monitoring in the workplaceAI monitoring in the workplace
AI monitoring in the workplaceStephanie Locke
 
Working with relational data in Microsoft Azure
Working with relational data in Microsoft AzureWorking with relational data in Microsoft Azure
Working with relational data in Microsoft AzureStephanie Locke
 
Win more, win faster with sales automation
Win more, win faster with sales automationWin more, win faster with sales automation
Win more, win faster with sales automationStephanie Locke
 
AI in manufacturing - a technical perspective
AI in manufacturing - a technical perspectiveAI in manufacturing - a technical perspective
AI in manufacturing - a technical perspectiveStephanie Locke
 

Plus de Stephanie Locke (19)

Let's banish "it works on my machine"
Let's banish "it works on my machine"Let's banish "it works on my machine"
Let's banish "it works on my machine"
 
How to build brilliant managers.pdf
How to build brilliant managers.pdfHow to build brilliant managers.pdf
How to build brilliant managers.pdf
 
Developer Velocity
Developer VelocityDeveloper Velocity
Developer Velocity
 
The Microsoft Well Architected Framework For Data Analytics
The Microsoft Well Architected Framework For Data AnalyticsThe Microsoft Well Architected Framework For Data Analytics
The Microsoft Well Architected Framework For Data Analytics
 
Sustainable manufacturing with AI
Sustainable manufacturing with AISustainable manufacturing with AI
Sustainable manufacturing with AI
 
Wrangling data like a boss
Wrangling data like a bossWrangling data like a boss
Wrangling data like a boss
 
Digitalisation from the back office to the factory floor
Digitalisation from the back office to the factory floorDigitalisation from the back office to the factory floor
Digitalisation from the back office to the factory floor
 
The fundamentals of regression
The fundamentals of regressionThe fundamentals of regression
The fundamentals of regression
 
Practical AI & data science ethics
Practical AI & data science ethicsPractical AI & data science ethics
Practical AI & data science ethics
 
Help There’s Too Many [Something]Ops!
Help There’s Too Many [Something]Ops!Help There’s Too Many [Something]Ops!
Help There’s Too Many [Something]Ops!
 
Reproducible machine learning
Reproducible machine learningReproducible machine learning
Reproducible machine learning
 
AI monitoring in the workplace
AI monitoring in the workplaceAI monitoring in the workplace
AI monitoring in the workplace
 
Working with relational data in Microsoft Azure
Working with relational data in Microsoft AzureWorking with relational data in Microsoft Azure
Working with relational data in Microsoft Azure
 
Win more, win faster with sales automation
Win more, win faster with sales automationWin more, win faster with sales automation
Win more, win faster with sales automation
 
Build or buy AI?
Build or buy AI?Build or buy AI?
Build or buy AI?
 
AI in manufacturing - a technical perspective
AI in manufacturing - a technical perspectiveAI in manufacturing - a technical perspective
AI in manufacturing - a technical perspective
 
The historian and AI
The historian and AIThe historian and AI
The historian and AI
 
AI for marketers
AI for marketersAI for marketers
AI for marketers
 
AI in manufacturing
AI in manufacturingAI in manufacturing
AI in manufacturing
 

Dernier

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 

Dernier (20)

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 

Working with data using Azure Functions.pdf

  • 1. Working with data using Azure Functions Liam Moat Steph Locke
  • 2. What we’re here to talk about • What are Azure Functions? • How to position serverless for your workloads • Using Azure Functions for data processing
  • 3. Steph & Liam Steph Locke Tw: @theStephLocke Li: stephanielocke GH: stephlocke Liam Moat Li: liammoatcom GH: liammoat
  • 5. Level of abstraction Focus on business logic Physical server Virtual machine PaaS Containerization Serverless
  • 6. No infrastructure management Developers can just focus on their code—without needing to worry about provisioning and managing infrastructure Instant, event- driven scalability Application components react to events and triggers in near real-time with virtually unlimited scalability Pay-per-use Only pay for what you use: billing is typically calculated on the number of function calls, code execution time, and memory used* *Supporting services, like storage and networking, may be charged separately.
  • 7. Functions-as-a-Service programming model use functions to achieve true serverless compute Single responsibility Functions are single- purposed, reusable pieces of code that process an input and return a result Short-lived Functions don’t stick around when finished executing, freeing up resources for further executions Stateless Functions don’t hold any persistent state and don’t rely on the state of any other processes Event-driven and scalable Functions respond to predefined events, and are instantly replicated as many times as needed
  • 8. An event-based, serverless compute experience that accelerates app development Integrated programming model Use built-in triggers and bindings to define when a function is invoked and to what data it connects End-to-end development experience Take advantage of a complete, end-to-end development experience with Functions—from building and debugging locally on major platforms like Windows, macOS, and Linux to deploying and monitoring in the cloud Hosting options flexibility Choose the deployment model that better fits your business needs without compromising development experience Fully managed and cost-effective Automated and flexible scaling based on your workload volume, keeping the focus on adding value instead of managing infrastructure
  • 9. Integrated programming model Azure Functions features input/output bindings which provide a means of pulling data or pushing data to other services. These bindings work for both Microsoft and third-party services without the need to hard-code integrations. Trigger Input binding Output binding Trigger object Your code Input object Output object
  • 10. The “Old” Way - Pseudocode func Run() { var connectionString = CloudConfigurationManager.GetSetting("storage:connection") var storageAccount = CloudStorageAccount.Parse(connectionString) var eventHubClient = EventHubClient.CreateFromConnectionString(eventHubConnection) func Poll() { var queueClient = storageAccount.CreateCloudQueueClient() var queue = queueClient.GetQueueReference("myqueue-items") queue.CreateIfNotExists() var msg = queue.PeekMessage().AsString var tableClient = storageAccount.CreateCloudTableClient() var table = tableClient.GetTableReference("people") table.CreateIfNotExists() var customer = table.Execute(TableOperation.Retrieve<Customer>(“Customer”, msg)) // do something with customer - business logic goes here. eventHubClient.Send(new EventData(...)) queue.DeleteMessage(msg); Sleep(10 seconds) Poll() } Poll() }
  • 11. Triggers - Pseudocode func Run([QueueTrigger("myqueue-items")] string msg) { var connectionString = CloudConfigurationManager.GetSetting("storage:connection") var storageAccount = CloudStorageAccount.Parse(connectionString) var eventHubClient = EventHubClient.CreateFromConnectionString(eventHubConnection) var tableClient = storageAccount.CreateCloudTableClient() var table = tableClient.GetTableReference("people") table.CreateIfNotExists() var customer = table.Execute(TableOperation.Retrieve<Customer>("Customer", msg)) // do something with customer - business logic goes here. eventHubClient.Send(new EventData(...)) }
  • 12. Inputs - Pseudocode func Run([QueueTrigger("myqueue-items")] string myQueueItem [Table("people", "my-partition", "{queueTrigger}")] Customer customer) { var eventHubClient = EventHubClient.CreateFromConnectionString(eventHubConnection) // do something with customer - business logic goes here. eventHubClient.Send(new EventData(...)) }
  • 13. Outputs - Pseudocode [return: EventHub("event-hub", Connection = "EventHubConnection")] Func EventData Run([QueueTrigger("myqueue-items")] string myQueueItem [Table("MyTable", "MyPartition", "{queueTrigger}")] Customer customer) { // do something with customer - business logic goes here. return new EventData(...) }
  • 14. Streamlining connections and improving security Use Managed Identities for downstream connections and for clients that invoke Functions Leverage Azure Key Vault for services without support for MI Managed Identities and Key Vault secrets allows others to manage access and minimises risk of leaked credentials Use Azure Functions v4 for MI support
  • 15. Managed Identities + Infrastructure as Code FTW Step 1: Assign the Managed Identity access to resources Step 2: Add simplified values to app settings Step 3: Use simple connection references in Functions
  • 16. DEMO: Creating an Azure Function project IaC (bicep), VS Code (Azure Functions and bicep extensions), Azure Function Core Tools, Github Copilot
  • 18. Automation of scheduled tasks S C E N A R I O E X A M P L E Financial services A customer database is analyzed for duplicate entries every 15 minutes, to avoid multiple communications being sent out to same customers A function cleans a database every 15 minutes… …deduplicating entries based on business logic
  • 19. Handling data with a schedule Timer.cs [FunctionName("TimerTriggerCSharp")] public static void Run([TimerTrigger("0 */5 * * * *")]TimerInfo myTimer, ILogger log) { // Business logic goes here… } Use NCRONTAB specifications for schedules Schedules can be managed in appsettings to put all schedules in a single location Use inputs and outputs to handle whatever you need to do
  • 20. Real-time stream processing S C E N A R I O E X A M P L E ISV Huge amounts of telemetry data is collected from a massive cloud app. That data is processed in near real-time and stored in a DB for use in an analytics dashboard App or device producing data Event Hubs ingests telemetry data A function processes the data… …and sends it to Cosmos DB Data used for dashboard visualizations
  • 21. Handling events Queue.cs public static class QueueFunctions { [FunctionName("QueueTrigger")] public static void QueueTrigger( [QueueTrigger("items")] string myQueueItem, ILogger log) { // Business logic goes here… } } Use a trigger that listens to an event publisher Process messages with a schema to improve quality Choose to process single messages or micro-batches
  • 22. Handling data on change S C E N A R I O E X A M P L E Financial Services Colleagues use mobile banking to reimburse each other for lunch: the person who paid for lunch requests payment through his mobile app, triggering a notification on his colleagues’ phones.
  • 23. Handling data when there’s changes CosmosDB.cs [FunctionName("CosmosTrigger")] public static void Run([CosmosDBTrigger( databaseName: "CorpDB", containerName: "CorpDB", Connection = "CorpDB", LeaseContainerName = "leases")]IReadOnlyList<Person> documents, ILogger log) { // Business logic goes here… } Use a trigger for a source that has CDC – primarily Cosmos DB and Azure SQL Process messages with a schema to improve quality Use inputs to get additional record sets to support processing
  • 24. Handling data on request S C E N A R I O E X A M P L E Professional Services A SaaS solution provides extensibility through webhooks, which can be implemented through Functions, to automate certain workflows.
  • 25. Handling data when requested HTTP.cs [FunctionName("HttpTriggerCSharp")] public static async Task<IActionResult> Run( [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req, ILogger log) { // Business logic goes here… } Use HTTP triggers to create APIs or webhook driven activities Use OpenAPI decorators to add documentation to your functions Use Managed Identity on resources that connect or do pass through auth where possible
  • 26. ? Workflows and orchestration with Durable Functions P A T T E R N S / U S E C A S E S Durable Functions is an extension of Azure Functions that lets you write stateful functions in a serverless compute environment Manageable sequencing + error handling/compensation Fanning out and fanning in External events correlation Flexible automated long-running process monitoring Start Get status Http-based async long- running APIs Human interaction
  • 27. Handling data with multiple steps Durable.cs [FunctionName("Chaining")] public static async Task<object> Run( [OrchestrationTrigger] IDurableOrchestrationContext context) { var x = await context.CallActivityAsync<object>("F1", null); await context.CallActivityAsync<object>("F2", x); } Orchestrate complex or stateful data flows using Durable Functions Use for different cases like aggregating, fanning out, human in the loop, or chaining functions
  • 28. DEMO: Creating different Azure Functions VS Code (Azure Functions & Azurite extensions), Azure Functions Core Tools, Github Copilot, Event Hub, Azure SQL, CosmosDB
  • 30. What we talked about • What are Azure Functions? • How to position serverless for your workloads • Using Azure Functions for data processing
  • 31. Try it yourself Learn with our Cloud Skills Challenge aka.ms/sqlbits-dwf Check out our repo to see things in detail aka.ms/sqlbits-dwf-demo Give it ago with free Azure resources Free Services