Containers, App Service and Functions
Virtual machines are not the only way to run code in Azure. Containers, serverless functions and App Service are often simpler and cheaper.
Containers
A container packages an application with everything it needs (libraries, settings) into a lightweight unit. Unlike a VM, a container shares the host's operating system kernel, so it starts in seconds and uses far fewer resources. Docker is the best-known container format.
Azure's container services:
| Service | What it is | Use it when |
|---|---|---|
| the fastest, simplest way to run a container; PaaS, no VMs to manage | you want to run a single container or a short job | |
| serverless containers with built-in load balancing and scaling | you want to run microservices without managing a cluster | |
| managed Kubernetes for orchestrating many containers | you run large, complex applications made of many containers |
Azure Functions
Azure Functions is serverless compute that runs your code in response to an event: an HTTP request, a message in a queue, a file in storage, or a timer.
- No servers to manage; it scales automatically.
- On the consumption plan you pay only while your code runs.
- Functions can be stateless (the default) or stateful with Durable Functions.
Use Functions for short pieces of work triggered by events, such as resizing an image when it is uploaded.
Azure App Service
Azure App Service is a fully managed PaaS for hosting web apps, REST APIs and mobile back ends. You deploy your code (in .NET, Java, Node.js, Python, PHP and more) and Azure handles the servers, the operating system, patching, load balancing and scaling. It runs on Windows or Linux, and deploys straight from GitHub or Azure DevOps.
App Service hosts four kinds of app:
- Web apps: websites and web applications.
- API apps: REST APIs, with support for Swagger/OpenAPI.
- WebJobs: background programs or scripts that run alongside a web app.
- Mobile apps: back ends for iOS and Android apps, with data storage, sign-in and push notifications.
Choosing where to host an application
| Need | Choose |
|---|---|
| Full control of the OS, legacy software | |
| A website or API without managing servers | |
| Code that runs briefly when something happens | |
| A packaged, portable application |