{"action":"created","comment":{"url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/pulls/comments/65634351","id":65634351,"diff_hunk":"@@ -0,0 +1,90 @@\n+﻿// Setup\n+// 1) Go to https://www.microsoft.com/cognitive-services/en-us/computer-vision-api \n+//    Sign up for computer vision api\n+// 2) Go to Function app settings -> App Service settings -> Settings -> Application settings\n+//    create a new app setting FACEAPI_Subscription_Key and use Computer vision key as value\n+#r \"Microsoft.WindowsAzure.Storage\"\n+#r \"Newtonsoft.Json\"\n+\n+using System.Net;\n+using System.Net.Http;\n+using System.Net.Http.Headers;\n+using Newtonsoft.Json;\n+using Microsoft.WindowsAzure.Storage.Table;\n+using System.IO;\n+\n+public static async Task Run(Stream image, string name, ICollector<FaceRectangle> outTable, TraceWriter log)\n+{\n+    string result = await CallFaceAPI(image);\n+    log.Info(result);\n+\n+    if (String.IsNullOrEmpty(result))\n+    {\n+        return;\n+    }\n+\n+    ImageData imageData = JsonConvert.DeserializeObject<ImageData>(result);\n+    foreach (Face face in imageData.faces)\n+    {\n+        FaceRectangle faceRectangle = face.faceRectangle;\n+        faceRectangle.RowKey = Guid.NewGuid().ToString();\n+        faceRectangle.PartitionKey = \"Functions\";\n+        faceRectangle.imageFile = name + \".jpg\";\n+        outTable.Add(faceRectangle);\n+    }\n+}\n+\n+static async Task<string> CallFaceAPI(Stream image)\n+{\n+    using (var client = new HttpClient())\n+    {\n+        var content = new StreamContent(image);\n+        var url = \"https://api.projectoxford.ai/vision/v1.0/analyze?visualFeatures=Faces\";\n+        client.DefaultRequestHeaders.Add(\"Ocp-Apim-Subscription-Key\", Environment.GetEnvironmentVariable(\"FACEAPI_Subscription_Key\"));\n+        content.Headers.ContentType = new MediaTypeHeaderValue(\"application/octet-stream\");\n+        var httpResponse = await client.PostAsync(url, content);\n+\n+        if (httpResponse.StatusCode == HttpStatusCode.OK)\n+        {\n+            return await httpResponse.Content.ReadAsStringAsync();\n+        }\n+    }\n+    return null;\n+}\n+\n+public class ImageData\n+{\n+    [JsonProperty(\"faces\")]\n+    public List<Face> faces { get; set; }\n+}\n+\n+public class Face\n+{\n+\n+    [JsonProperty(\"age\")]\n+    public int age { get; set; }","path":"Templates/FaceLocator-CSharp/run.csx","position":65,"original_position":65,"commit_id":"2898941e54b11ba6aa0ceebe2bec87dd5ec306de","original_commit_id":"2898941e54b11ba6aa0ceebe2bec87dd5ec306de","user":{"login":"fabiocav","id":2507935,"avatar_url":"https://avatars.githubusercontent.com/u/2507935?v=3","gravatar_id":"","url":"https://api.github.com/users/fabiocav","html_url":"https://github.com/fabiocav","followers_url":"https://api.github.com/users/fabiocav/followers","following_url":"https://api.github.com/users/fabiocav/following{/other_user}","gists_url":"https://api.github.com/users/fabiocav/gists{/gist_id}","starred_url":"https://api.github.com/users/fabiocav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fabiocav/subscriptions","organizations_url":"https://api.github.com/users/fabiocav/orgs","repos_url":"https://api.github.com/users/fabiocav/repos","events_url":"https://api.github.com/users/fabiocav/events{/privacy}","received_events_url":"https://api.github.com/users/fabiocav/received_events","type":"User","site_admin":false},"body":"nit: Since we're using the JsonProperty attribute, use the usual casing convention for properties (Pascal)","created_at":"2016-06-02T23:07:33Z","updated_at":"2016-06-02T23:07:33Z","html_url":"https://github.com/Azure/azure-webjobs-sdk-templates/pull/219#discussion_r65634351","pull_request_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/pulls/219","_links":{"self":{"href":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/pulls/comments/65634351"},"html":{"href":"https://github.com/Azure/azure-webjobs-sdk-templates/pull/219#discussion_r65634351"},"pull_request":{"href":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/pulls/219"}}},"pull_request":{"url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/pulls/219","id":72260107,"html_url":"https://github.com/Azure/azure-webjobs-sdk-templates/pull/219","diff_url":"https://github.com/Azure/azure-webjobs-sdk-templates/pull/219.diff","patch_url":"https://github.com/Azure/azure-webjobs-sdk-templates/pull/219.patch","issue_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/issues/219","number":219,"state":"open","locked":false,"title":"Adding C# FaceLocator template using Computer Vision Api","user":{"login":"soninaren","id":8119379,"avatar_url":"https://avatars.githubusercontent.com/u/8119379?v=3","gravatar_id":"","url":"https://api.github.com/users/soninaren","html_url":"https://github.com/soninaren","followers_url":"https://api.github.com/users/soninaren/followers","following_url":"https://api.github.com/users/soninaren/following{/other_user}","gists_url":"https://api.github.com/users/soninaren/gists{/gist_id}","starred_url":"https://api.github.com/users/soninaren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/soninaren/subscriptions","organizations_url":"https://api.github.com/users/soninaren/orgs","repos_url":"https://api.github.com/users/soninaren/repos","events_url":"https://api.github.com/users/soninaren/events{/privacy}","received_events_url":"https://api.github.com/users/soninaren/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-06-01T22:04:52Z","updated_at":"2016-06-02T23:07:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5df0f7ad355dfe3df13a4a6b80e451db4af92f38","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/pulls/219/commits","review_comments_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/pulls/219/comments","review_comment_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/issues/219/comments","statuses_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/statuses/2898941e54b11ba6aa0ceebe2bec87dd5ec306de","head":{"label":"soninaren:FaceLocator","ref":"FaceLocator","sha":"2898941e54b11ba6aa0ceebe2bec87dd5ec306de","user":{"login":"soninaren","id":8119379,"avatar_url":"https://avatars.githubusercontent.com/u/8119379?v=3","gravatar_id":"","url":"https://api.github.com/users/soninaren","html_url":"https://github.com/soninaren","followers_url":"https://api.github.com/users/soninaren/followers","following_url":"https://api.github.com/users/soninaren/following{/other_user}","gists_url":"https://api.github.com/users/soninaren/gists{/gist_id}","starred_url":"https://api.github.com/users/soninaren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/soninaren/subscriptions","organizations_url":"https://api.github.com/users/soninaren/orgs","repos_url":"https://api.github.com/users/soninaren/repos","events_url":"https://api.github.com/users/soninaren/events{/privacy}","received_events_url":"https://api.github.com/users/soninaren/received_events","type":"User","site_admin":false},"repo":{"id":53429290,"name":"azure-webjobs-sdk-templates","full_name":"soninaren/azure-webjobs-sdk-templates","owner":{"login":"soninaren","id":8119379,"avatar_url":"https://avatars.githubusercontent.com/u/8119379?v=3","gravatar_id":"","url":"https://api.github.com/users/soninaren","html_url":"https://github.com/soninaren","followers_url":"https://api.github.com/users/soninaren/followers","following_url":"https://api.github.com/users/soninaren/following{/other_user}","gists_url":"https://api.github.com/users/soninaren/gists{/gist_id}","starred_url":"https://api.github.com/users/soninaren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/soninaren/subscriptions","organizations_url":"https://api.github.com/users/soninaren/orgs","repos_url":"https://api.github.com/users/soninaren/repos","events_url":"https://api.github.com/users/soninaren/events{/privacy}","received_events_url":"https://api.github.com/users/soninaren/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/soninaren/azure-webjobs-sdk-templates","description":"","fork":true,"url":"https://api.github.com/repos/soninaren/azure-webjobs-sdk-templates","forks_url":"https://api.github.com/repos/soninaren/azure-webjobs-sdk-templates/forks","keys_url":"https://api.github.com/repos/soninaren/azure-webjobs-sdk-templates/keys{/key_id}","collaborators_url":"https://api.github.com/repos/soninaren/azure-webjobs-sdk-templates/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/soninaren/azure-webjobs-sdk-templates/teams","hooks_url":"https://api.github.com/repos/soninaren/azure-webjobs-sdk-templates/hooks","issue_events_url":"https://api.github.com/repos/soninaren/azure-webjobs-sdk-templates/issues/events{/number}","events_url":"https://api.github.com/repos/soninaren/azure-webjobs-sdk-templates/events","assignees_url":"https://api.github.com/repos/soninaren/azure-webjobs-sdk-templates/assignees{/user}","branches_url":"https://api.github.com/repos/soninaren/azure-webjobs-sdk-templates/branches{/branch}","tags_url":"https://api.github.com/repos/soninaren/azure-webjobs-sdk-templates/tags","blobs_url":"https://api.github.com/repos/soninaren/azure-webjobs-sdk-templates/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/soninaren/azure-webjobs-sdk-templates/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/soninaren/azure-webjobs-sdk-templates/git/refs{/sha}","trees_url":"https://api.github.com/repos/soninaren/azure-webjobs-sdk-templates/git/trees{/sha}","statuses_url":"https://api.github.com/repos/soninaren/azure-webjobs-sdk-templates/statuses/{sha}","languages_url":"https://api.github.com/repos/soninaren/azure-webjobs-sdk-templates/languages","stargazers_url":"https://api.github.com/repos/soninaren/azure-webjobs-sdk-templates/stargazers","contributors_url":"https://api.github.com/repos/soninaren/azure-webjobs-sdk-templates/contributors","subscribers_url":"https://api.github.com/repos/soninaren/azure-webjobs-sdk-templates/subscribers","subscription_url":"https://api.github.com/repos/soninaren/azure-webjobs-sdk-templates/subscription","commits_url":"https://api.github.com/repos/soninaren/azure-webjobs-sdk-templates/commits{/sha}","git_commits_url":"https://api.github.com/repos/soninaren/azure-webjobs-sdk-templates/git/commits{/sha}","comments_url":"https://api.github.com/repos/soninaren/azure-webjobs-sdk-templates/comments{/number}","issue_comment_url":"https://api.github.com/repos/soninaren/azure-webjobs-sdk-templates/issues/comments{/number}","contents_url":"https://api.github.com/repos/soninaren/azure-webjobs-sdk-templates/contents/{+path}","compare_url":"https://api.github.com/repos/soninaren/azure-webjobs-sdk-templates/compare/{base}...{head}","merges_url":"https://api.github.com/repos/soninaren/azure-webjobs-sdk-templates/merges","archive_url":"https://api.github.com/repos/soninaren/azure-webjobs-sdk-templates/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/soninaren/azure-webjobs-sdk-templates/downloads","issues_url":"https://api.github.com/repos/soninaren/azure-webjobs-sdk-templates/issues{/number}","pulls_url":"https://api.github.com/repos/soninaren/azure-webjobs-sdk-templates/pulls{/number}","milestones_url":"https://api.github.com/repos/soninaren/azure-webjobs-sdk-templates/milestones{/number}","notifications_url":"https://api.github.com/repos/soninaren/azure-webjobs-sdk-templates/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/soninaren/azure-webjobs-sdk-templates/labels{/name}","releases_url":"https://api.github.com/repos/soninaren/azure-webjobs-sdk-templates/releases{/id}","deployments_url":"https://api.github.com/repos/soninaren/azure-webjobs-sdk-templates/deployments","created_at":"2016-03-08T16:55:05Z","updated_at":"2016-04-13T00:39:44Z","pushed_at":"2016-06-02T23:00:30Z","git_url":"git://github.com/soninaren/azure-webjobs-sdk-templates.git","ssh_url":"git@github.com:soninaren/azure-webjobs-sdk-templates.git","clone_url":"https://github.com/soninaren/azure-webjobs-sdk-templates.git","svn_url":"https://github.com/soninaren/azure-webjobs-sdk-templates","homepage":null,"size":249,"stargazers_count":0,"watchers_count":0,"language":"PowerShell","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Azure:dev","ref":"dev","sha":"48fd7048f9b50da041d0e28e2950070218029c27","user":{"login":"Azure","id":6844498,"avatar_url":"https://avatars.githubusercontent.com/u/6844498?v=3","gravatar_id":"","url":"https://api.github.com/users/Azure","html_url":"https://github.com/Azure","followers_url":"https://api.github.com/users/Azure/followers","following_url":"https://api.github.com/users/Azure/following{/other_user}","gists_url":"https://api.github.com/users/Azure/gists{/gist_id}","starred_url":"https://api.github.com/users/Azure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Azure/subscriptions","organizations_url":"https://api.github.com/users/Azure/orgs","repos_url":"https://api.github.com/users/Azure/repos","events_url":"https://api.github.com/users/Azure/events{/privacy}","received_events_url":"https://api.github.com/users/Azure/received_events","type":"Organization","site_admin":false},"repo":{"id":52470131,"name":"azure-webjobs-sdk-templates","full_name":"Azure/azure-webjobs-sdk-templates","owner":{"login":"Azure","id":6844498,"avatar_url":"https://avatars.githubusercontent.com/u/6844498?v=3","gravatar_id":"","url":"https://api.github.com/users/Azure","html_url":"https://github.com/Azure","followers_url":"https://api.github.com/users/Azure/followers","following_url":"https://api.github.com/users/Azure/following{/other_user}","gists_url":"https://api.github.com/users/Azure/gists{/gist_id}","starred_url":"https://api.github.com/users/Azure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Azure/subscriptions","organizations_url":"https://api.github.com/users/Azure/orgs","repos_url":"https://api.github.com/users/Azure/repos","events_url":"https://api.github.com/users/Azure/events{/privacy}","received_events_url":"https://api.github.com/users/Azure/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Azure/azure-webjobs-sdk-templates","description":"","fork":false,"url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates","forks_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/forks","keys_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/teams","hooks_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/hooks","issue_events_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/issues/events{/number}","events_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/events","assignees_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/assignees{/user}","branches_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/branches{/branch}","tags_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/tags","blobs_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/git/refs{/sha}","trees_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/statuses/{sha}","languages_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/languages","stargazers_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/stargazers","contributors_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/contributors","subscribers_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/subscribers","subscription_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/subscription","commits_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/commits{/sha}","git_commits_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/git/commits{/sha}","comments_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/comments{/number}","issue_comment_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/issues/comments{/number}","contents_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/contents/{+path}","compare_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/merges","archive_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/downloads","issues_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/issues{/number}","pulls_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/pulls{/number}","milestones_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/milestones{/number}","notifications_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/labels{/name}","releases_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/releases{/id}","deployments_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/deployments","created_at":"2016-02-24T19:53:25Z","updated_at":"2016-05-30T16:56:29Z","pushed_at":"2016-06-02T23:00:31Z","git_url":"git://github.com/Azure/azure-webjobs-sdk-templates.git","ssh_url":"git@github.com:Azure/azure-webjobs-sdk-templates.git","clone_url":"https://github.com/Azure/azure-webjobs-sdk-templates.git","svn_url":"https://github.com/Azure/azure-webjobs-sdk-templates","homepage":null,"size":374,"stargazers_count":9,"watchers_count":9,"language":"PowerShell","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":10,"mirror_url":null,"open_issues_count":14,"forks":10,"open_issues":14,"watchers":9,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/pulls/219"},"html":{"href":"https://github.com/Azure/azure-webjobs-sdk-templates/pull/219"},"issue":{"href":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/issues/219"},"comments":{"href":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/issues/219/comments"},"review_comments":{"href":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/pulls/219/comments"},"review_comment":{"href":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/pulls/219/commits"},"statuses":{"href":"https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/statuses/2898941e54b11ba6aa0ceebe2bec87dd5ec306de"}}}}
{"actor":{"display_login":"fabiocav"}}