{"action":"created","issue":{"url":"https://api.github.com/repos/sjkp/letsencrypt-siteextension/issues/175","repository_url":"https://api.github.com/repos/sjkp/letsencrypt-siteextension","labels_url":"https://api.github.com/repos/sjkp/letsencrypt-siteextension/issues/175/labels{/name}","comments_url":"https://api.github.com/repos/sjkp/letsencrypt-siteextension/issues/175/comments","events_url":"https://api.github.com/repos/sjkp/letsencrypt-siteextension/issues/175/events","html_url":"https://github.com/sjkp/letsencrypt-siteextension/issues/175","id":274131928,"number":175,"title":"Add Azure Function example in nodejs","user":{"login":"manuel-guilbault","id":718466,"avatar_url":"https://avatars2.githubusercontent.com/u/718466?v=4","gravatar_id":"","url":"https://api.github.com/users/manuel-guilbault","html_url":"https://github.com/manuel-guilbault","followers_url":"https://api.github.com/users/manuel-guilbault/followers","following_url":"https://api.github.com/users/manuel-guilbault/following{/other_user}","gists_url":"https://api.github.com/users/manuel-guilbault/gists{/gist_id}","starred_url":"https://api.github.com/users/manuel-guilbault/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/manuel-guilbault/subscriptions","organizations_url":"https://api.github.com/users/manuel-guilbault/orgs","repos_url":"https://api.github.com/users/manuel-guilbault/repos","events_url":"https://api.github.com/users/manuel-guilbault/events{/privacy}","received_events_url":"https://api.github.com/users/manuel-guilbault/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-11-15T12:01:38Z","updated_at":"2017-11-19T12:46:49Z","closed_at":"2017-11-19T12:46:49Z","author_association":"NONE","body":"Since my own Azure Function was in nodejs, I had to try to rewrite in javascript the function example handling the ACME challenge (written in C# in the wiki). It might be cool for future users if it was added to the wiki:\r\n\r\n```js\r\nconst fs = require('fs');\r\n\r\nmodule.exports = function(context, request) {\r\n  const responseFilePath = `D:\\\\home\\\\site\\\\wwwroot\\\\.well-known\\\\acme-challenge\\\\${context.bindingData.code}`;\r\n\r\n  context.log(`Checking for ACME challenge response at '${responseFilePath}'...`);\r\n\r\n  fs.exists(responseFilePath, (exists) => {\r\n    if (!exists) {\r\n      context.log(`ACME challenge response file '${responseFilePath}' not found.`);\r\n      context.done(null, {\r\n        status: 404,\r\n        headers: { \"Content-Type\": \"text/plain\" },\r\n        body: 'ACME challenge response not found.'\r\n      });\r\n      return;\r\n    }\r\n\r\n    context.log(`ACME challenge response file '${responseFilePath}' found. Reading file...`);\r\n    fs.readFile(responseFilePath, (error, data) => {\r\n      if (error) {\r\n        context.log.error(`An error occured while reading file '${responseFilePath}'.`, error);\r\n        context.done(null, { status: 500 });\r\n        return;\r\n      }\r\n\r\n      context.log(`ACME challenge response file '${responseFilePath}' read successfully.`);\r\n      context.done(null, {\r\n        status: 200,\r\n        headers: { \"Content-Type\": \"text/plain\" },\r\n        body: data\r\n      });\r\n    });\r\n  });\r\n};\r\n```"},"comment":{"url":"https://api.github.com/repos/sjkp/letsencrypt-siteextension/issues/comments/345513910","html_url":"https://github.com/sjkp/letsencrypt-siteextension/issues/175#issuecomment-345513910","issue_url":"https://api.github.com/repos/sjkp/letsencrypt-siteextension/issues/175","id":345513910,"user":{"login":"sjkp","id":3397744,"avatar_url":"https://avatars3.githubusercontent.com/u/3397744?v=4","gravatar_id":"","url":"https://api.github.com/users/sjkp","html_url":"https://github.com/sjkp","followers_url":"https://api.github.com/users/sjkp/followers","following_url":"https://api.github.com/users/sjkp/following{/other_user}","gists_url":"https://api.github.com/users/sjkp/gists{/gist_id}","starred_url":"https://api.github.com/users/sjkp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sjkp/subscriptions","organizations_url":"https://api.github.com/users/sjkp/orgs","repos_url":"https://api.github.com/users/sjkp/repos","events_url":"https://api.github.com/users/sjkp/events{/privacy}","received_events_url":"https://api.github.com/users/sjkp/received_events","type":"User","site_admin":false},"created_at":"2017-11-19T12:46:49Z","updated_at":"2017-11-19T12:46:49Z","author_association":"OWNER","body":"Thanks, I added it https://github.com/sjkp/letsencrypt-siteextension/wiki/Azure-Functions-Support#nodejs "}}
{"actor":{"display_login":"sjkp"}}