Azure函数未给出有效的Base-64字符串错误 [英] Azure function is giving not a valid Base-64 string error
问题描述
我有一个带有CosmosDB输出绑定的http-trigger和一个最简单的函数,如下所示.
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字符,两个以上的填充字符或填充字符中的非法字符
我正在使用天蓝色函数的V2. 我观察到删除输出绑定是可行的.因此,似乎此输出绑定已解决问题.
local.settings内容如下
{ 已加密":false, 值":{ "AzureWebJobsStorage":"UseDevelopmentStorage = true", "FUNCTIONS_WORKER_RUNTIME":"dotnet", "MongoDBEndPoint":"AccountEndpoint = https://abc.documents.azure.com:10255 ; AccountKey = xxxxxxxxxxxxyyyyyyyzzzzzzzzz ", "MongoDBName":"haveThatDB" } }
任何帮助将不胜感激.
Azure Cosmos DB绑定仅支持与SQL API一起使用.对于所有其他Azure Cosmos DB API,应使用API的静态客户端从函数访问数据库,包括API的MongoDB API,Cassandra API,Gremlin API和Table API. 受支持的API
I have a http-trigger with a CosmosDB output binding and a simplest of a function as below.
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");
}
}
when i executed i get an error
Exception binding parameter 'requestOutput'. System.Private.CoreLib: The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters
i am using V2 of azure functions.
i have observed that removing the output binding works. so looks like something is up with this output binding.
local.settings contents are as below
{ "IsEncrypted": false, "Values": { "AzureWebJobsStorage": "UseDevelopmentStorage=true", "FUNCTIONS_WORKER_RUNTIME": "dotnet", "MongoDBEndPoint": "AccountEndpoint=https://abc.documents.azure.com:10255;AccountKey=xxxxxxxxxxxxyyyyyyyyzzzzzzz", "MongoDBName": "haveThatDB" } }
any help will be appreciated.
Azure Cosmos DB bindings are only supported for use with the SQL API. For all other Azure Cosmos DB APIs, you should access the database from your function by using the static client for your API, including MongoDB API, Cassandra API, Gremlin API, and Table API. Supported APIs
Azure Cosmos DB bindings for Azure Functions 2.x
这篇关于Azure函数未给出有效的Base-64字符串错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!