Skip to content

Instantly share code, notes, and snippets.

@vainolo
Created October 25, 2018 13:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vainolo/f8ebd6f3741f3f0f76c560af885b60a2 to your computer and use it in GitHub Desktop.
Save vainolo/f8ebd6f3741f3f0f76c560af885b60a2 to your computer and use it in GitHub Desktop.
Azure Functions – Part 2: Serving HTML Pages with Azure Functions - Option 3 - body
// Option 3, read from external blob
var storageAccount = CloudStorageAccount.Parse("[your azure storage connection string]");
var blobClient = storageAccount.CreateCloudBlobClient();
var container = blobClient.GetContainerReference("site");
var blob = container.GetBlockBlobReference("hello.html");
string text = "";
using (var memoryStream = new MemoryStream())
{
blob.DownloadToStream(memoryStream);
text = System.Text.Encoding.UTF8.GetString(memoryStream.ToArray());
}
var response = req.CreateResponse(HttpStatusCode.OK);
response.Content = new StringContent(text);
response.Content.Headers.ContentType = new MediaTypeHeaderValue("text/html");
return response;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment