I wanted to try out Azure Functions to see if I can serve html data from Azure Functions that I get from another third party site. As in, if I use RestSharp and call another site from my Azure Function, extract its content and just display it as output to html. This can come in handy, lets say you have a proxy that is blocking you to get to certain sites and you just want to extract some data from the site and process it. Since Azure function is so cheap, I thought I would give it a try.

Here is a sequence diagram to explain the idea of it.

azureFuncBrowser

azureFuncBrowser

So the idea is quite simple, you make an Azure Function that can serve you the site html since you are blocked to access it.

We first need to go and create ourselves a HttpTrigger C# function in azure. If you wish to learn more about how to create an HTTP trigger you can read my previous post on Timer Event Trigger which is very similar to http trigger.

First we will need to add a new file called project.json, such that we can add our RestSharp Nuget package.

For our code we will write just a simple GET call with RestSharp and serve it back as a stream

You can then just simply view the Url of your azure function by calling it in a browser. Yes the images wont show up property, but all we want is the html to extract some data of, so we are ok that images dont show up properly.

cbc

cbc

There you have it to serve html data from third party site with Azure Functions.