我有一个带有CosmosDB输出绑定的http触发器和一个最简单的函数,如下所示。
public static class AddRequest
{
[FunctionName("AddRequest")]
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req,
ILogger log, [CosmosDB(
databaseName: "haveThatDB",
collectionName: "Requests",
ConnectionStringSetting = "MongoDBEndPoint",CreateIfNotExists =true)] IAsyncCollector<Request> requestOutput
)
{
string jsonContent = await req.ReadAsStringAsync();
dynamic data = JsonConvert.DeserializeObject(jsonContent);
await requestOutput.AddAsync(data);
return req != null
? (ActionResult)new OkObjectResult($"Hello, ras")
: new BadRequestObjectResult("Please pass a name on the query string or in the request body");
}
}
当我执行时,我得到一个错误
异常绑定参数'requestOutput'。System.Private.CoreLib:输入不是有效的Base-64字符串,因为它包含非Base 64字符、两个以上的填充字符或填充字符中的非法字符
我正在使用azure函数的V2。
local.settings内容如下
{
“IsEncrypted”:错误,
“AzureWebJobsStorage”:“UseDevelopmentStorage=true”,
“函数\u工作者\u运行时”:“dotnet”,
“MongoDBEndPoint”:“AccountEndpoint”=
https://abc.documents.azure.com:10255;AccountKey=xxxxxxxxxxxxyyyyyyyyzzzzzzz
“MongoDBName”:“haveThatDB”
}
}