我正在尝试练习“ Mastering Xamarin.Forms”第三版中的练习。我已按照书中的说明通过门户添加功能应用程序。
run.csx文件如下:
#r "Newtonsoft.Json"
#r "microsoft.WindowsAzure.Storage"
using System.Net;
using microsoft.AspNetCore.Mvc;
using microsoft.Extensions.Primitives;
using microsoft.WindowsAzure.Storage;
using microsoft.WindowsAzure.Storage.Table;
using Newtonsoft.Json;
public static async Task<IactionResult> Run(HttpRequest req,Newtonsoft.Json.Linq.JArray entryTableInput,IAsyncCollector<Entry> entryTableOutput,ILogger log)
{
log.LogInformation(req.Method);
if (req.Method == "GET")
{
return (actionResult) new OkObjectResult(entryTableInput);
}
var requestBody = await new StreamReader(req.Body).ReadToEndAsync();
var entry = JsonConvert.DeserializeObject<Entry>(requestBody);
if (entry != null)
{
await entryTableOutput.AddAsync(entry);
return (actionResult) new OkObjectResult(entry);
}
return new BadRequestObjectResult("Invalid entry request.");
}
public class Entry
{
public string Id => Guid.NewGuid().ToString("n");
public string Title { get; set; }
public double Latitude { get; set; }
public double Longitude { get; set; }
public DateTime Date { get; set; }
public int Rating { get; set; }
public string Notes { get; set; }
// Required for Table Storage entities
public string PartitionKey => "ENTRY";
public string RowKey => Id;
}
function.json:
{
"bindings": [
{
"authLevel": "anonymous","name": "req","type": "httpTrigger","direction": "in"
},{
"name": "$return","type": "http","direction": "out"
},{
"type": "table","name": "entryTableOutput","tableName": "entry","connection": "AzureWebJobStorage","name": "entryTableInput","take": 50,"connection": "AzureWebJobsStorage","direction": "in"
}
],"disabled": false
}
我正在使用Postman来测试请求。 GET和POST都返回500内部服务器错误。我不知道下一步该怎么做。