Azure App Service
Azure App Service is a cloud-based platform for hosting web applications, REST APIs, and mobile backends. It supports a variety of programming languages and frameworks, and allows for easy scaling and deployment.
☰ Key Features
☰ Built-in Auto Scale Support
Scale up or down to match changing demands, with automatic scaling of resources such as cores and RAM.
Autoscaling
☰ Types of Scaling
There are two main ways that an application can scale:
- Vertical scaling, also called scaling up and down, means to change the capacity of a resource.
- Horizontal scaling, also called scaling out and in, means adding or removing instances of a resource.
☰ Autoscaling Components
An autoscaling strategy typically involves the following components:
- Instrumentation and monitoring systems at the application, service, and infrastructure levels.
- Decision-making logic evaluates live usage metrics against predefined thresholds or schedules and decides whether to scale.
- Components and mechanisms perform the scaling action.
- Testing, monitoring, and tuning capabilities for the autoscaling strategy.
☰ Configure Autoscaling for an Azure Solution
Azure provides built-in autoscaling for most compute options.
- Azure virtual machines autoscale via virtual machine scale sets.
- Azure Service Fabric supports autoscaling through virtual machine scale sets.
- Azure App Service has built-in autoscaling.
- Azure Functions automatically allocates compute power when your code runs.
☰ Custom Autoscaling Solution
A custom autoscaling solution can sometimes be useful. For example, you could use Azure Diagnostics and application-based metrics, along with custom code to monitor and export the application metrics.
However, a custom solution isn't simple to implement and should be considered only if none of the previous approaches can fulfill your requirements.
☰ Best Practices
Use the built-in autoscaling features of the platform if they meet your requirements.
If not, carefully consider whether you need more complex scaling features.
https://learn.microsoft.com/en-us/azure/azure-monitor/autoscale/autoscale-get-started
Autoscaling Best Practices
https://learn.microsoft.com/en-us/azure/architecture/best-practices/auto-scaling
☰ Container Support
Deploy and run containerized web apps on Windows and Linux, with support for Docker Hub and Azure Container Registry.
Azure Container Services
Azure provides several container-related services, including:
- Azure Kubernetes Service (AKS)
- Azure Container Apps
- Azure Red Hat OpenShift
- Azure Container Registry
- Azure Container Storage
☰ AKS vs Azure Container Apps
While both AKS and Azure Container Apps are services for running containerized applications on Azure, they have different use cases.
| Service | Description | Use Case |
|---|---|---|
| AKS | Managed Kubernetes service with direct access to Kubernetes APIs | Advanced scenarios, hybrid and multicloud deployments, direct access to Kubernetes API required |
| Azure Container Apps | Serverless, fully managed environment with event-driven architecture and automatic scaling | Developers who don't want to interact with Kubernetes, building and deploying applications without managing infrastructure |
☰ Azure Container Apps vs Azure Container Instances
Both services are for running containers on Azure, but they serve different purposes.
| Service | Description | Use Case |
|---|---|---|
| Azure Container Apps | Serverless, fully managed environment with event-driven architecture and automatic scaling | Applications that need to scale based on demand, complex microservice architectures |
| Azure Container Instances | Lower-level building block option for running containers without managing servers | Running isolated containers quickly and efficiently in transient scenarios, not intended for enterprise-grade backends |
☰ Pricing and Free Tiers
Azure provides monthly free amounts for several services for the first 12 months, and some services are always free.
- AKS cluster management is always free, but you incur a charge for resources consumed by nodes.
- Azure Container Apps is free for up to 180,000 vCPU seconds, 360,000 GiB seconds, and 2 million requests.
- Azure Container Registry is free for the first 12 months and up to 1 Standard tier registry with 100 GB storage and 10 webhooks.
https://azure.microsoft.com/en-us/products/category/containers
☰ Limitations of App Service on Linux
- Not supported on Shared pricing tier
- Azure portal shows only features that currently work for Linux apps
- Higher disk latency for storage volumes
☰ App Service Environment
App Service Environment provides a fully isolated and dedicated environment for running App Service apps, with improved security at high scale.
Unlike regular App Service, App Service Environment offers dedicated compute resources and improved security features.
☰ App Service Environment Overview
An App Service Environment is an Azure App Service feature that provides a fully isolated and dedicated environment for running App Service apps securely at high scale.
☰ Benefits of App Service Environment
App Service Environments are ideal for application workloads that require:
- High scale
- Isolation and secure network access
- High memory utilization
- High requests per second (RPS)
☰ Usage Scenarios
App Service Environments have many use cases, including:
- Internal line-of-business applications
- Applications that need more than 30 App Service plan instances
- Single-tenant systems to satisfy internal compliance or security requirements
- Network-isolated application hosting
- Multi-tier applications
☰ Dedicated Environment
An App Service Environment is a single-tenant deployment of Azure App Service that runs on your virtual network.
Applications are hosted in App Service plans, which are created in an App Service Environment.
☰ Virtual Network Support
The App Service Environment feature is a deployment of Azure App Service into a single subnet on a virtual network.
The apps in an App Service Environment don't need any features enabled to access resources on the same virtual network that the App Service Environment is in.
☰ Feature Differences
App Service Environment v3 differs from earlier versions in the following ways:
- No networking dependencies on the customer's virtual network
- Zone redundancy can be enabled at creation time or any time after deployment
- Scaling is faster than with an App Service Environment v2
- Front-end scaling adjustments are no longer required
☰ Pricing
The pricing model for App Service Environment v3 varies depending on the type of App Service Environment deployment you have.
The three pricing models are:
- App Service Environment v3
- Zone redundant App Service Environment v3
- Dedicated host App Service Environment v3
https://learn.microsoft.com/en-us/azure/app-service/environment/overview
https://learn.microsoft.com/en-us/training/modules/introduction-to-azure-app-service/2-azure-app-service
☰ App Service Plans
An App Service plan defines a set of compute resources for a web app to run. One or more apps can be configured to run on the same computing resources (or in the same App Service plan).
☰ Key Features
Each App Service plan defines:
- Operating System (Windows, Linux)
- Region (West US, East US, etc.)
- Number of VM instances
- Size of VM instances (Small, Medium, Large)
- Pricing tier (Free, Shared, Basic, Standard, Premium, PremiumV2, PremiumV3, Isolated, IsolatedV2)
☰ Pricing Tiers
The pricing tier of an App Service plan determines what App Service features you get and how much you pay for the plan. There are a few categories of pricing tiers:
- Shared compute: Free and Shared, the two base tiers, runs an app on the same Azure VM as other App Service apps, including apps of other customers.
- Dedicated compute: The Basic, Standard, Premium, PremiumV2, and PremiumV3 tiers run apps on dedicated Azure VMs. Only apps in the same App Service plans share the same compute resources.
- Isolated: The Isolated and IsolatedV2 tiers run dedicated Azure VMs on dedicated Azure Virtual Networks. It provides network isolation on top of compute isolation to your apps.
☰ How Does My App Run and Scale?
In the Free and Shared tiers, an app receives CPU minutes on a shared VM instance and can't scale out. In other tiers, an app runs and scales as follows:
- An app runs on all the VM instances configured in the App Service plan.
- If multiple apps are in the same App Service plan, they all share the same VM instances.
- If you have multiple deployment slots for an app, all deployment slots also run on the same VM instances.
- If you enable diagnostic logs, perform backups, or run WebJobs, they also use CPU cycles and memory on these VM instances.
☰ What If My App Needs More Capabilities or Features?
Your App Service plan can be scaled up and down at any time. It's as simple as changing the pricing tier of the plan.
If your app is in the same App Service plan with other apps, you might want to improve the app's performance by isolating the compute resources. You can do it by moving the app into a separate App Service plan.
☰ Isolating Your App
You can potentially save money by putting multiple apps into one App Service plan. However, since apps in the same App Service plan all share the same compute resources you need to understand the capacity of the existing App Service plan and the expected load for the new app.
Isolate your app into a new App Service plan when:
- The app is resource-intensive.
- You want to scale the app independently from the other apps in the existing plan.
- The app needs resource in a different geographical region.
https://learn.microsoft.com/en-us/training/modules/introduction-to-azure-app-service/3-azure-app-service-plans
☰ Deploy to App Service
App Service supports both automated and manual deployment. Automated deployment, or continuous deployment, is a process used to push out new features and bug fixes in a fast and repetitive pattern with minimal effect on end users.
☰ Automated Deployment
Azure supports automated deployment directly from several sources:
- Azure DevOps Services: You can push your code to Azure DevOps Services, build your code in the cloud, run the tests, generate a release from the code, and finally, push your code to an Azure Web App.
- GitHub: Azure supports automated deployment directly from GitHub. When you connect your GitHub repository to Azure for automated deployment, any changes you push to your production branch on GitHub are automatically deployed for you.
- Bitbucket: With its similarities to GitHub, you can configure an automated deployment with Bitbucket.
☰ Manual Deployment
There are a few options that you can use to manually push your code to Azure:
- Git: App Service web apps feature a Git URL that you can add as a remote repository. Pushing to the remote repository deploys your app.
- CLI: webapp up is a feature of the az command-line interface that packages your app and deploys it. Unlike other deployment methods, az webapp up can create a new App Service web app for you.
- Zip deploy: Use curl or a similar HTTP utility to send a ZIP of your application files to App Service.
- FTP/S: FTP or FTPS is a traditional way of pushing your code to many hosting environments, including App Service.
☰ Use Deployment Slots
Whenever possible, use deployment slots when deploying a new production build. When using a Standard App Service Plan tier or better, you can deploy your app to a staging environment and then swap your staging and production slots.
☰ Continuously Deploy Code
If your project designates branches for testing, QA, and staging, then each of those branches should be continuously deployed to a staging slot. This allows your stakeholders to easily assess and test the deployed branch.
☰ Continuously Deploy Containers
For custom containers from Azure Container Registry or other container registries, deploy the image into a staging slot and swap into production to prevent downtime.
The automation is more complex than code deployment because you must push the image to a container registry and update the image tag on the webapp.
☰ Sidecar Containers
In Azure App Service, you can add up to nine sidecar containers for each sidecar-enabled custom container app. Sidecar containers let you deploy extra services and features to your container application without making them tightly coupled to your main application container.
For example, you can add monitoring, logging, configuration, and networking services as sidecar containers.
https://learn.microsoft.com/en-us/training/modules/introduction-to-azure-app-service/4-deploy-code-to-app-service
Image courtesy of Microsoft.com
Image courtesy of
Microsoft.com