Azure function is giving not a valid Base-64 string error

社会主义新天地 提交于 2019-12-24 22:12:19

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/52822472/azure-function-is-giving-not-a-valid-base-64-string-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!