Skip to content

Instantly share code, notes, and snippets.

@kennetham
Created July 4, 2017 08:48
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 kennetham/bda6601a9a740d5666905da31794ae37 to your computer and use it in GitHub Desktop.
Save kennetham/bda6601a9a740d5666905da31794ae37 to your computer and use it in GitHub Desktop.
Azure Function Forwarding Message to Azure App Service
const https = require('https');
module.exports = function (context, req) {
// Obtain message from request.
const post_data = JSON.stringify(req.body);
// Obtain token from request.
// Required to forward to bot.
const authorization = req.headers.authorization;
const post_options = {
host: 'botservicetest.azurewebsites.net',
port: '443',
path: '/api/messages',
method: 'POST',
headers: {
'content-type': 'application/json',
'content-length': Buffer.byteLength(post_data),
'authorization': authorization
}
};
const post_req = https.request(post_options);
// Post the data
post_req.write(post_data);
post_req.on('error', (e) => {
context.log(e);
});
post_req.end();
context.done();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment