Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Serverless compute on Windows in AWS

I've got a piece of code that I need to make available over the 'Net. It's a perfect fit for an AWS Lambda with an HTTP API on top - a stateless, side effect free, rather CPU intensive function, blob in, blob out. It's written in C#/.NET, but it's not pure .NET, it makes use of the UWP API, therefore requires Windows Server 2016.

AWS Lambdas only run on Linux hosts, even C# ones. Is there any way to deploy this piece in the Amazon cloud in serverless manner - maybe something other than a Lambda? I know I can go with a EC2 VM, but this is the very kind of thing serverless architecture was invented for.

like image 868
Seva Alekseyev Avatar asked Dec 15 '16 03:12

Seva Alekseyev


1 Answers

Lambda is the only option for serverless computing on AWS and Lambda functions run only on Linux machines.

If you need to run serverless functions in a Windows machine, try Azure Functions. That's the Lambda equivalent in the Microsoft cloud. I'm not sure if it runs in a Windows Server 2016 machine and couldn't find any reference to the platform, but I would expect that, as a brand new service, they are using their own edge tech.

To confirm if the platform is what you need, try this function:

using System.Management;
using System.Net;
using System.Threading.Tasks;    

public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log)
{
    // Get OS friendly name
    // http://stackoverflow.com/questions/577634/how-to-get-the-friendly-os-version-name
    var caption = (from x in new ManagementObjectSearcher("SELECT Caption FROM Win32_OperatingSystem").Get().Cast<ManagementObject>()
                  select x.GetPropertyValue("Caption")).FirstOrDefault();
    string name = caption != null ? caption.ToString() : "Unknown";

    // the function response
    return req.CreateResponse(HttpStatusCode.OK, name);
}
like image 192
Zanon Avatar answered Nov 14 '22 19:11

Zanon