This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/******************************************************************************* | |
* Copyright (c) 2012 Arieh 'Vainolo' Bibliowicz | |
* You can use this code for educational purposes. For any other uses | |
* please contact me: [email protected] | |
*******************************************************************************/ | |
package com.vainolo.examples.net; | |
import java.io.BufferedInputStream; | |
import java.io.BufferedOutputStream; | |
import java.io.File; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/******************************************************************************* | |
* Copyright (c) 2012 Arieh 'Vainolo' Bibliowicz | |
* You can use this code for educational purposes. For any other uses | |
* please contact me: [email protected] | |
*******************************************************************************/ | |
package com.vainolo.examples.file; | |
import java.io.BufferedInputStream; | |
import java.io.BufferedOutputStream; | |
import java.io.File; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Net; | |
public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log) | |
{ | |
log.Info("C# HTTP trigger function processed a request."); | |
// parse query parameter | |
string name = req.GetQueryNameValuePairs().FirstOrDefault(q => string.Compare(q.Key, "name", true) == 0).Value; | |
if (name == null) | |
{ | |
// Get request body | |
dynamic data = await req.Content.ReadAsAsync<object>(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#r "Newtonsoft.Json"using System.Net; | |
using Newtonsoft.Json; | |
using Newtonsoft.Json.Linq; | |
public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log) | |
{ | |
log.Info("C# HTTP trigger function processed a request."); | |
string name = null; | |
if (req.Method == HttpMethod.Post) | |
{ | |
log.Info($"POST method was used to invoke the function"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Net; | |
using System.Net.Http.Headers; | |
public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log) | |
{ | |
log.Info("C# HTTP trigger function processed a request."); | |
// Option 1, coded HTML | |
var response = req.CreateResponse(HttpStatusCode.OK, "Hello "); | |
response.Content.Headers.ContentType = new MediaTypeHeaderValue("text/html"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Hello</title> | |
</head> | |
<body> | |
World | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Option 2, read from local file | |
var response = new HttpResponseMessage(HttpStatusCode.OK); | |
var stream = new FileStream(@"d:\home\site\wwwroot\HelloWorldHTML\hello.html", FileMode.Open); | |
response.Content = new StreamContent(stream); | |
response.Content.Headers.ContentType = new MediaTypeHeaderValue("text/html"); | |
return response; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#r "Microsoft.WindowsAzure.Storage" | |
using System.Net; | |
using System.Net.Http.Headers; | |
using Microsoft.WindowsAzure.Storage; | |
using Microsoft.WindowsAzure.Storage.Blob; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Net; | |
public static async Task&lt;HttpResponseMessage&gt; Run(HttpRequestMessage req, TraceWriter log) | |
{ | |
log.Info("C# HTTP trigger function processed a request."); | |
return req.CreateResponse(HttpStatusCode.OK, "Hello World"); | |
} |
OlderNewer