IntroductionMicrosoft's Azure cloud service is blending yet more PaaS and IaaS services with its new Service Fabric developer framework.When you build cloud services, they need to be built as scalable, distributed systems that can go from a handful of customers to a million if the service takes off, and will always be available even if the network gets slow or there are server failures.If you build on a public cloud platform like Azure or AWS, the cloud platform will have that scalable, distributed fault tolerance itself, but you have to build it into your own apps yourself - and that's hard. Especially as your service will have to keep evolving as you add features, but also stay stable even when you're updating it.Azure solutionThat's what the new Azure Service Fabric is for, Azure CTO Mark Russinovich explained to TechRadar Pro. "Traditional tools that people use to develop applications just aren't up to the job of maintaining that kind of complexity with the reliability and flexibility and availability these services require."Developers have been hand rolling their own solutions to this, which explains the rise in open source solutions and cluster orchestrators and containerisation - but the fact is these solutions are not really solving the full spectrum of problems that developers are facing."The Azure team knows those problems pretty well, because they have to help the teams behind Microsoft cloud services like Visual Studio Online and Cortana to solve them. "This technology isn't just something we've been working on just for a few months and are popping out and shoving over the wall here," says Russinovich."It's something that we've been running for five years inside Microsoft. It powers a growing number of Azure services as well as general Microsoft services. Everything from Azure Database to Skype for Business to Cortana, to Service Bus, Event Hubs, to Intune, to DocumentDB and more - they're all running on our service fabric. And what we're releasing isn't just a version of that or just something that's like what we're powering these internal services on; it's the exact same bits."More control, less complexityUsually, developers get a choice between using PaaS and only being able to do what the platform allows, or using IaaS and having to handle all the complexity themselves. Azure Service Fabric gives you the control but takes care of the complexities of scaling and updating and maintaining a service that you're running in the cloud (or on your own servers).Service Fabric can work with microservices where you explicitly care about the state of every transaction as well as ones where you leave the platform to take care of that. "There's nothing else out there that supports stateful microservices," claims Russinovich. "Of course this supports stateless microservices like you see people developing on top of containers but it also supports stateful microservices like DocumentDB and Azure Database.""Service Fabric is designed from the ground up with a microservices approach to cloud service architecture," he notes. "It's kind of unique in that it really understands the binding between microservices, your application and the underlying infrastructure, the cluster that those run on."Take Microsoft's Azure Database service, which is running two million active databases on tens of thousands of databases - that's all done with the service fabric, says Russinovich. "Each one of those databases is represented as three or four microservice replicas and each one of those replicas has a copy of a database in a different server in a different track. Service Fabric is responsible for honouring those placement requirements, saying these microservices have to be on different servers in different racks."The only thing the Azure database developers worry about is 'a request came into my microservice and I'm going to commit it to my durable-state store'. Service fabric is what's responsible for routing those requests to the primary of those three replicas and it also takes care of 'how do I get that state replicated to those secondary replicas?' It does that all automatically under the hood. The developer can make multiple changes to the state in a transactionally consistent way and those transactions are implemented by the service fabric."Cloud trends for 2015: hybrid cloud set to become the strategy of choiceUpdating and actor modelUpdate issuesCloud services have to run all the time, but they also need regular updates - and too often, that's when problems happen. "One of the challenges is how do I update microservices while I keep my service available to clients - and how do I deal with any problems I introduce in an update? Service Fabric supports fully automatic updates with rolling updates."Only parts of the microservice that's offering functionality get taken down at a time. It has health monitoring with watchdogs, and the facility for automatic rollback - if there are problems it can move back to a known good state. There's health monitoring for VM failures, for service failures, for microservice failures."If something goes wrong, Service Fabric can automatically heal your service. "If a server fails, say it's the primary server - it detects that failure and promotes the secondary to the primary and heals the old primary in place if it can, or creates a new instance on a healthy server and catches that one up - all behind the scenes. That is truly rocket science distributed systems stuff," claims Russinovich. "In terms of what you can do, all these things I've mentioned - rolling updates with rollback and healing and health monitoring and watchdogs and stateful replication - I'm just scratching the surface."And building an app to take advantage of all this doesn't have to be complicated either. There are low-level commands that the developers at Microsoft who build services like AzureDB use, but there are also higher-level commands you can use with Service Fabric. "If you're familiar with distributed dictionaries in .NET like key-value stores and queues, we will have that exact same programming model," Russinovich explains, "backed by stateful replication with support for transactions."You could take a distributed dictionary and update it and put a message in a queue all within Service Fabric, and it will then be committed across all those replicas I talked about."Actor modelBut Service Fabric also has a much simpler, higher-level programming system called an actor model. Actors are virtual - you can always program against them and the system takes care of creating them when they're needed, and garbage collecting them when they're not, so they're very efficient. And it takes care of spreading them out over different clusters to make sure you have enough resources when you need to scale up and pass messages between them. The actor model handles transactions and availability and consistency for you and it's a very powerful way of building cloud services far more simply.You might have heard of this from the Project Orleans .NET framework from MSR that all the cloud services for Halo 4 are built in (everything from finding someone to play against to the record of every shot fired in every game is stored as actors using Orleans)."Orleans was an incubation that we're now productising on top of the Azure Service Fabric," explains Russinovich. "I'm really excited about this, especially on top of the Service Fabric foundation that's really hardened by all the usage inside Microsoft. This really democratises stateful distributed programming - which is the hardest there is."And as you'd expect from the new Microsoft, you get plenty of choice in where you can use Service Fabric. The initial languages for developers are C++, C# and .NET but Russinovich says Microsoft will bring out other languages that developers ask for. And while Service Fabric will come out first as an SDK for Windows, he notes "we're working on making it available later on Linux for startups that have chosen to build on top of Linux."It doesn't even have to run on Azure (although that's where it makes most sense because that gives you the cloud scale). "You can put the Service Fabric on your own servers or on other clouds and later we'll be releasing it as a service in Azure as well as on the Azure Pack. You can put it on your own cluster, or on a single box for integrated debugging with Visual Studio. You can put it on whichever server you want including very small ones," promises Russinovich. "A key focus of ours is that people can take advantage of this, without fear of being locked into something."Azure isn't just Microsoft's cloud - it's the company's Cloud OS