Update - April 2, 2014 - * Answering this question, since it appears as one of the first results in popular machines, when searching for installing Microsoft.NET framework 4.5.1 on the Azure Cloud service.
The easiest way is to set the osFamily attribute to "4" in the cloud service configuration file (.cscfg file). This will invoke an instance of Windows Server 2012 R2 with Microsoft.NET 4.5.1 installed.
Example:
<ServiceConfiguration serviceName="CloudDeploymentShell" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="4" osVersion="*" ...
source share