Anthony Chu Contact Me

Serving an HTML Page from Azure Functions

Sunday, April 10, 2016

I was playing around with building an API using Azure Functions this weekend. I wanted to see if I can host the HTML frontend for interacting with it on Azure Functions as well. Because Functions with an HTTP trigger automatically comes with an HTTP endpoint with optional built-in API key authentication (no API gateway required!), this is really easy.

Update - March 10, 2017: Check out this post on how to serve multiple files from a directory.

Create an HttpTrigger Function

If there isn't a Function App already, the first step is to go into the Azure Portal and create one. Then create an HttpTrigger C# function. This example is in .NET, but we should be able to do this with Node.js and other technologies as well.

The function is pretty simple, and it returns the HttpResponseMessage class that we're used to in ASP.NET Web API 2. We can create an HttpResponseMessage that has a content type of text/html and a FileStream of an HTML file that we'll create later. I couldn't find an elegant way of figuring out the full path to the function directory so I just hardcoded it. :) Here's the updated run.csx:

Continue Reading...


Running Scheduled Executables in Azure Functions

Wednesday, April 6, 2016

One of the many big announcements at Build 2016 was Azure Functions. It's Microsoft's entry into the serverless architecture space and their answer to Amazon Lambda.

With Azure Functions, we can deploy little units of code that are run on-demand or via an already large variety of triggers. We are only billed for resources consumed during code execution and scaling is all handled for us.

Today we'll look at how we can run existing Windows console applications on a scheduler in Azure Functions.

Continue Reading...


Closer Look: Hosting ASP.NET Core on Azure App Service

Sunday, April 3, 2016

Azure Web Apps on Azure App Service is probably the simplest way to host an ASP.NET Core app today. Currently, ASP.NET Core apps can be deployed seamlessly via Visual Studio publishing and Git deployment. The deployed application runs on App Service via the HttpPlatformHandler (soon to be replaced by the ASP.NET Core Module).

In this article, we'll take a closer look at what actually happens when an ASP.NET Core app is deployed and hosted in Azure App Service.

Continue Reading...


Deploying an ASP.NET Core App on an Azure Service Fabric Party Cluster

Sunday, March 27, 2016

The easiest way to try out Azure Service Fabric is by using the free "party clusters". Party clusters were created by the Service Fabric team as a low-friction way to try out the service for free, without having to provision any infrastructure.

The Service Fabric SDK (currently at v1.5.175) makes it pretty simple to create an ASP.NET Core application and deploy it locally; but the application needs a couple of tweaks before it will run on a remote cluster.

In this article we'll deploy an ASP.NET Core application to a Service Fabric party cluster.

Continue Reading...


Implementing Content Security Policy (CSP) in ASP.NET Core

Sunday, March 13, 2016

Content Security Policy (CSP) is an added layer of security that helps to detect and mitigate certain types of attacks, including Cross-Site Scripting (XSS) and data injection attacks. These attacks are used for everything from data theft to site defacement or distribution of malware.

-- MDN article on CSP

In this post we'll add CSP to an ASP.NET Core app.

Continue Reading...