Going serverless on Azure
Azure overview
Serverless computing
Static hosting ( storage )
Backend Api ( functions )
Jobs ( functions )
Queuing ( storage )
Database ( serverless )
Azure B2C
Code Hosting
Pipelines
Local development
Demo App
What is Azure ?
Microsoft currently operates more than 200 datacenters. Its currently operating and planned datacenters are located in 34 countries worldwide.
North Holland
Project Natick
& Serverless !
Azure offer
The Azure cloud platform is more than 200 products and cloud services
Serverless computing...
Benefits of serverless
Serverless application pattern
Azure storage
( blobs )
What is it?
Blob storage
A binary large object (BLOB) is a collection of binary data stored as a single entity.
Blob storage is designed for:
- Serving images or documents directly to a browser.
- Storing files for distributed access.
- Streaming video and audio.
- Writing to log files.
- Storing data for backup and restore, disaster recovery, and archiving.
- Storing data for analysis by an on-premises or Azure-hosted service.
Static hosting
You can serve static content (HTML, CSS, JavaScript, and image files) directly from a storage container named $web.
Azure Storage static website hosting is a great option in cases where you don't require a web server to render content.
How about a domain name?
Backend Api (functions)
What is it?
Azure Functions is a serverless solution that allows you to write less code, maintain less infrastructure, and save on costs.
Instead of worrying about deploying and maintaining servers, the cloud infrastructure provides all the up-to-date resources needed to keep your applications running.
C# | JavaScript | Java | Python | Rust |Go Power Shell
A Trigger, as the name might imply, is an event that start the Azure Function
Bindings are a construct inside of an Azure Function that enables you to communicate with other services (Azure or external) .The bindings (both input and output) are passed to the Azure Function as a parameter when the function is executed.
Triggers & Bindings
Azure Functions types
Securing Azure Functions (default)
[FunctionName("HttpTriggerCSharp")]
public static Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Anonymous)] HttpRequest req)
{
...
}
- anonymous - No API key is required.
- function - A function-specific API key is required. This is the default value if none is provided.
- admin - The master key is required.
Scheduled Jobs (functions)
What is it?
The time-triggered Azure Function allows us to schedule time for executing the function. It means that it triggers the function on a specified time. It works as CRON expressions work. When creating a time-triggered function, we need to specify a time in CRON format that determines when the trigger will execute.
[FunctionName("TimerTriggerCSharp")]
public static void Run([TimerTrigger("0 */5 * * * *")]TimerInfo myTimer, ILogger log)
{
if (myTimer.IsPastDue)
{
log.LogInformation("Timer is running late!");
}
log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
}
Example
https://github.com/atifaziz/NCrontab
NCronTab
Queuing (storage)
What is Azure Queue Storage?
Azure Queue Storage is a service for storing large numbers of messages. You access messages from anywhere in the world via authenticated calls using HTTP or HTTPS. A queue message can be up to 64 KB in size. A queue may contain millions of messages, up to the total capacity limit of a storage account.
public static class QueueFunctions
{
[FunctionName("QueueTrigger")]
public static void QueueTrigger(
[QueueTrigger("myqueue-items")] string myQueueItem,
ILogger log)
{
log.LogInformation($"C# function processed: {myQueueItem}");
}
}
[FunctionName("QueueOutput")]
[return: Queue("myqueue-items")]
public static string Run([HttpTrigger] dynamic input, ILogger log)
{
...
}
Examples
Database (serverless)
The serverless compute tier for single databases in Azure SQL Database is parameterized by a compute autoscaling range and an auto-pause delay.
Azure SQL serveless
Pricing
Azure B2C
What is B2C ?
Azure Active Directory B2C provides business-to-customer identity as a service. Your customers use their preferred social, enterprise, or local account identities to get single sign-on access to your applications and APIs.
Microsoft Authentication Library (MSAL)
Code Hosting
Pipelines
Monitoring & Error tracking
Azure Application insights
It is used to monitor your live applications. It will automatically detect performance anomalies, and includes powerful analytics tools to help you diagnose issues and to understand what users actually do with your app.
Local development
Windows
- Visual Studio (Community) 2019 - 2022 /JB Rider
- Visual Studio Code
- npm install -g azure-functions-core-tools@3 --unsafe-perm true
-
Azure Storage Explorer (win)
- Azurite : local emulator for storage, queue and table storage
- npm install -g azurite
MacOS
- Visual Studio (Community) 2019 - 2022 /JB Rider
- Visual Studio Code
- npm install -g azure-functions-core-tools@3 --unsafe-perm true
- brew install azure-functions-core-tools
-
Azure Storage Explorer (mac)
- Azurite : local emulator for storage, queue and table storage
- npm install -g azurite
demo app
GO build something on Azure!
Thank you!
@imhotepp
2021
Serverless in Azure
By Dragosh
Serverless in Azure
Deploy, run and monitor serverless aplication in Azure
- 135