我已經創建了簡單的azure函數(Http + C#),它返回簡單的test.I想要返回azure函數對azure移動服務的響應。在我從移動服務調用存儲過程之前,現在我試圖調用那個azure函數(節點Js)想要從azure函數獲取響應。 Azure的移動服務代碼及以下如何從Azure移動應用程序服務調用HTTP(Azure函數)?
module.exports = {
"post": function (req, res, next) {
console.log("Started Application Running");
var http = require("http");
var options = {
host: "<appname>.azurewebsites.net",
path: "api/<functionname>?code=<APIkey>",
method: "POST",
headers : {
"Content-Type":"application/json",
"Content-Length": { name : "Testing application"}
}
};
http.request(options, function(response) {
var str = "";
response.on("data", function (chunk) {
str += chunk;
res.json(response);
console.log("Something Happens");
});
response.on("end", function() {
console.log(str);
res.json(response);
});
});
console.log("*** Sending name and address in body ***");
}
};
這裏是我蔚藍的功能
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;
string name = "divya";
// Get request body
dynamic data = await req.Content.ReadAsAsync<object>();
// Set name to query string or body data
name = name ?? data?.name;
return name == null
? req.CreateResponse(HttpStatusCode.BadRequest, "Please pass a name on the query string or in the request body")
: req.CreateResponse(HttpStatusCode.OK, "Hello Welcome ");
}
。可任何一個可以幫助我,我簡單的蔚藍功能的腳本?
什麼是你目前有確切的問題? – Mikhail
當我運行移動服務時出現內部服務器錯誤。我試圖解決我不知道確切的解決方案。 – divya