Hosting web application on Azure
Coming to cloud with web application can be scary if it’s the first time you do it. Azure cloud is not anymore about dozen of services – it’s real monster offering more than we are able to know and learn. It’s not easy to predict what will be the final path on cloud but it is possible to tell how to get started. Here’s how to do it.
Cloud mindset
Guys who are coming from in-prem world have to get used with one simple idea – there’s no box anymore as everything is service. Web server, NAS, file server, database server and so on – think of these as services.
Azure cloud is damn granular. Almost all components you can imagine your application is consuming are covered with appropriate services. There’s no single box anymore, there’s no server anymore – there are only services.
But there are VM-s, right? Yes, there are virtual machines and making practically copy of in-prem solution is supported scenario. Often it’s way more complex and expensive than hosting web application using existing Azure services. Of course, over time you will find things to host on small VM-s to cut expenses but you have to know damn well what you are doing.
Cloud economics
It’s easy to put everything up on cloud as it was in-prem and then discover that cloud is damn expensive. Cloud is not about planning resources with big enough resource reserves that cover the needs for next five years. There’s no reason go with expensive pricing tiers just because perhaps we grow to these tiers over coming years.
On cloud you can always give your services more resources by need. You can do it whenever you want. There’s no reason to gather resources in advance like squirrels gather peanuts before winter.
How cloud economy works? Start small, consume what your solution minimally needs to be stable, scale up by actual needs and scale down if needs decrease.
Hosting your web application on Azure
To get started I put up here on diagram to illustrate where you should start. I will also describe all Azure services shown and explain in simple language how to use and understand them. After this chapter I think you are ready start.
This is my proposed minimal set of services to get going with public web application.
App service host – the container where app services with web applications run. Consider app services host as a web server although on Azure it is God knows what. What you scale for web applications is app service host. Start with some cheap pricing tier and scale up if you need.
App service – it’s like virtual application on IIS. App service can host one or more web applications. You can deploy web applications to app service directly from Visual Studio while you set up Azure DevOps build and release pipelines. Don’t keep user uploaded files here as app service doesn’t scale well as file server and there are storage limits you face if you have gigabytes of files.
MSSQL – there’s hosted SQL Server available as a service on Azure and you can manage your databases using SQL Server Management Studio (SSMS). If you are using MySQL or PostgreSQL then these are available as services too and you can use your favorite tools to manage your databases. Whatever database you have – start from minimal pricing tiers and scale up is current tier doesn’t provide enough power.
Application Insights – is monitoring and diagnostic service for all kinds of applications. Using Visual Studio it’s easy to add it to existing web application. You will get more data about your running applications as ever before. On Azure you can build rich reports based on data collected by Application Insights and over time you will get skilled enough to stay always few steps ahead of possible problems. Application Insights is cheap if you don’t pile enormous amounts of data there.
Blob storage – as app services are optimized for running web applications and using them as file server is not supported scenario you need a place where you can keep content files. I mean files that you don’t deploy to cloud with your application. There are disk space limits on app services and you want to avoid these. Blob storage is excellent choice to keep static files. You can later make step further and server CSS ja JS files from blob storage too.
CDN – stands for Content Delivery Network. It’s a network of servers all over the world and using this on top of blob storage helps you cut storage costs. Visitors win too – all static content is served to them from geografically nearest server. You don’t have to create new subdomain for CDN while you are trying out Azure. All CDN end-points have their own SSL subdomain provided by Azure. Later you can use your own SSL subdomain if you like.
Workflows – if your application has background services or workflows then I suggest you to implement these as Azure Logic Apps or Azure Functions. Azure Functions is serverless computing offer by Microsoft and Azure Logic Apps is sort of replacement to old era workflows that were complex to build and host.
Azure DevOps pipelines – Azure DevOps allows you to host your code, manage your projects and deploy your applications. You can use your own source code repository and you can skip project management features if you don’t need them. Using Azure DevOps pipelines you can build up powerful CI and release solution with minimal costs. Build pipelines will build your applications and application components while release pipelines publish new versions to cloud. You can easily automate tons of things.
Architectural changes
Set of services shown above makes you probably ask what needs to be changed in application to make it real Azure cloud citizen. Some things you probably don’t need to change (database connectivity by example).
You have to externalize and generalize consuming all the resources that doesn’t live in same local network or same box anymore. Most popular is file system with uploaded files. You can go with my IFileClient generalization by example.
You can use blob storage on Azure and local file system client on dev box like I do. Using dependency injection it’s easy.
Also be ready to break real-time dependencies with background services. Often these dependencies were convenient to create when application was built. But on cloud we want application to be fast and not waiting for e-mail to be sent or SMS delivery report to be generated by SMS service.
Wrapping up
It takes you some work on your application to make it cloud ready but it’s worth it. After this you can go the path I proposed to host your web application on Azure. I chose app service hosting as it is the easiest one to start with and it has some very powerful features I didn’t covered in this post. Chances are still very good you will stay with app service when going live with your application.
References
- App Service – Build, deploy, and scale web apps on a fully managed platform
- Azure SQL Database – Managed, intelligent SQL in the cloud
- Blob Storage – Massively scalable object storage for unstructured data
- Content Delivery Network
- Azure Monitor (Application Insights) – Full observability into your applications, infrastructure, and network
- Azure Functions – More than just event-driven serverless compute
- Logic Apps – Quickly build powerful integration solutions
- Azure DevOps – Plan smarter, collaborate better, and ship faster with a set of modern dev services
Cloud economics Nice article