Azure Functions の Javascript のディフォールトのプログラムで Post の引数が渡らないので、それを検証しました。
Azure Functions のプログラムです。ディフォールトをメッセージを出すように改造しました。
index.js
module.exports = function (context, req) {
context.log('JavaScript HTTP trigger function processed a request.');
if (req.query.name || (req.body && req.body.name)) {
context.res = {
// status: 200, /* Defaults to 200 */
body: "Hello " + (req.query.name || req.body.name) + " " + req.method + "\n"
};
}
else {
var str_out = ""
str_out += "*** error ***\n"
str_out += "method = " + req.method + "\n"
str_out += "req.body = " + JSON.stringify(req.body) + "\n"
context.res = {
status: 400,
body: str_out
};
}
context.done();
};
まず、Get のテスト
$ curl -G https://ekzemplaro02.azurewebsites.net/api/HttpTriggerJS1?code=****== --
data 'name=jiro'
Hello jiro GET
次に -G を取って Post のテスト
$ curl https://ekzemplaro02.azurewebsites.net/api/HttpTriggerJS1?code=****== --
data 'name=jiro'
*** error ***
method = POST
req.body = "name=jiro"