In early 2016, Microsoft stated in a “Microsoft by the numbers” announcement that more than 25% of Azure virtual machines (VMs) were Linux. By the end of 2016, it was saying “nearly one in three”. In October 2017, it announced 40% of VMs in Azure were running Linux.
At last month’s Build developer conference, Corey Sanders, Microsoft corporate vice-president for Azure Compute, said it had risen to “more than 40% Linux”. He also said he’d be troubled if the share of Windows VMs on Azure were to shrink further.
The discussion goes to the heart of the wider question: what is happening to Microsoft’s platform? The slogan “Microsoft loves Linux” is not just empty words, as the Azure data confirms.
On the client side, Microsoft has abandoned Windows Phone in favour of developing its own applications for Apple iOS and Google Android. Microsoft Word for Android has been downloaded over 500 million times.
Windows Subsystem for Linux
Another notable development is the Windows 10 feature called Windows Subsystem for Linux (WSL). This is a remarkable piece of engineering that enables Linux binary code (native ELF64) to execute on Windows. Linux system calls are translated into Windows application programming interface (API) calls.
This enables Linux distributions – now including Ubuntu, openSuse, Suse Linux Enterprise, Debian and Kali – to be installed from the Windows Store. This feature is not aimed at general users, but rather at developers who now have access to a Linux toolchain in Windows – as well as the use of countless command-line utilities. There is no officially supported Linux graphical user interface (GUI), though it can be hacked.
Using WSL rather than a VM running Linux means deep integration, including access to the same file system, and the ability to launch Linux executables from Windows and Windows executables from WSL.
The reason is for WSL to remove friction for developers targeting Unix-like platforms. They can configure Windows 10 to run code editors on the Windows side (including Microsoft’s open source offering Visual Studio code), while compiling and running in WSL.
Microsoft has gradually improved WSL, and the latest version (in the April 2018 update to Windows 10, build 1803) has a number of enhancements. These include per-directory case-sensitive file names supported on the Windows side, as well as from Linux; Unix Sockets; background tasks; and a utility to convert path names between Windows and WSL.
Developers using Visual Studio code, with Node.js, can target WSL simply by setting the attribute “useWSL”: true in the launch configuration file.
Cross-platform .Net and developing for Linux with Visual Studio
Microsoft has undertaken several initiatives to make targeting Linux or cross-platform projects possible with Visual Studio. Enabling WSL is not essential. At the end of 2014, the company announced .Net Core, a fork of the .Net Framework which is open source and runs on Windows, Linux and Mac. Now at version 2.1, the supported platforms include the ARM-based Raspberry Pi. Indeed, .Net Core is supported by frameworks including ASP.Net Core and Entity Framework Core, both also at version 2.1.
Microsoft's container story
Microsoft’s container story is diverse, though, perhaps to the point of confusion. A developer can run a container in many different ways, including those detailed below.
- Azure Container Instance - This service came out of preview in April 2018. It lets you run a Windows or Linux container without creating a VM or cluster (a serverless model) and with automatic scaling. It is charged on central processing unit and memory usage per second. “We hear consistently from customers that ACI is uniquely suited to handle their burst workloads,” writes Sanders in a blog post. “ACI supports quick, cleanly packaged burst compute that removes the overhead of managing cluster machines.”
- App Service - The Web App for the Containers service lets you deploy containers with the same model as the Web App Service. There is easily configured scaling and load balancing, but it is not truly serverless; you pay for what is running regardless of usage, though you can set rules for automatic scaling. You can now run more than one container in a single App Service.
- Azure Kubernetes Service - This is for Linux containers orchestrated by a hosted Kubernetes service. You deploy a cluster using either the command line or via the Azure portal. Benefits of Kubernetes include configuring self-healing, scaling, load balancing, automated rollback (if needed), storage management and more.
- Azure Service Fabric - This supports both Windows and Linux containers. Service Fabric is a runtime for managing microservices. Whereas Kubernetes is widely used throughout the industry, Service Fabric is unique to Microsoft, though it can be run on-premise as well as in Azure. Service Fabric manages deployment, monitoring, upgrading, scaling and more. It supports an application framework called Reliable Actors for stateful services. Announced at Build was a preview of Service Fabric Mesh, which removes the need to manage clusters in favour of a serverless approach.
- Azure Batch - You can run containers in batch computing jobs using Linux or Windows. One thing that helps make sense of the diverse choices is the Azure Container Registry (ACR). This service, which uses an API compatible with the Docker Registry, lets developers manage container images and deploy them to all of the above services. This means it is now possible to set up a continuous integration or continuous delivery (CI/CD) process that pushes containers to ACR, and from ACR deployment to production.
Microsoft still supports the Windows-only .Net Framework, though the company has stated that new investment will be on .Net Core and not .Net Framework.
At Build, Microsoft announced the forthcoming .Net Core 3.0 will support Windows desktop applications, a key step in shunting .Net Framework towards a legacy support role.
The snag here is that .Net Core only supports a subset of .Net Framework features. Notable omissions are support for ASP.Net Web Forms, Windows Communication Foundation (WCF) services and Windows Workflow Foundation.
There is also a bias towards C# in .Net Core, meaning that while Visual Basic and F# are also supported, they do not support all project types.
On the other hand, there are also strong reasons to use .Net Core. Raw performance is generally better – sometimes dramatically so. It has also been designed with microservices in mind and runs nicely in both Linux and Windows containers.
In Visual Studio, targeting Linux containers with ASP.Net Core is a matter of installing Docker for Windows, which uses Hyper-V virtualisation, and adding Docker Linux support to the application via a right-click menu. Note that Microsoft now also offers SQL Server for Linux.
At the client end of a modern application, developers often have to write code for a smartphone, an iPad or a Chromebook rather than a PC.
To target the end-to-end stack, Microsoft required cross-platform mobile development tools, and in early 2016, it acquired Xamarin to obtain C# compilers for iOS and Android.
The Xamarin compilers are based on Mono, an earlier open source implementation of the .Net Framework, but Microsoft is now working to share as much code as possible between Xamarin and .Net Core.
Using Xamarin, developers can either write shared non-visual code and combine it with a native GUI for each platform or use an abstraction called Xamarin Forms to share GUI code as well. Both approaches use native platform GUI controls rather than emulating them with custom drawing.
At the Build conference, the Xamarin team announced a preview of support for Google’s Android Emulator on Hyper-V. This will resolve a pain point for developers, whereas the Android emulator requires Intel’s HAXM to be enabled, which disables Hyper-V.
Xamarin can also target the Mac desktop, though not from Visual Studio. Targeting MacOS must be done on a Mac, for example, using Visual Studio for the Mac.
Other options for mobile development
Developers can also write C++ code and compile for iOS and Android.
Microsoft’s Linux strategy
Might Windows development become a niche activity and Linux the mainstream – even on Microsoft’s platform?
The answer is that the company still has a strong incentive to promote Windows Server with its deep integration into Active Directory and other server products, including Exchange, Dynamics, SQL Server and so on.
This is more about Microsoft recognising that public web applications are already dominated by Linux, and that if customers are running on Azure it can prosper regardless of the preferred operating system.
The upside for Microsoft is that it can offer cloud services to developers working with Java, Node.js, PHP or other technologies without the friction of running on Windows.
Microsoft’s Linux support is also a key part of its microservices and DevOps story.
When the company talks about cloud-native applications, it means applications broken down into microservices and easily scaled.
Microservices generally also implies containers, though there is also a serverless platform called Azure Functions. Taking advantage of managed services such as Azure SQL or CosmosDB (Microsoft’s no-SQL database manager), rather than hosting a database server, reduces the maintenance burden and lets developers take advantage of the built-in scalability of these Azure services.