代码之家  ›  专栏  ›  技术社区  ›  Raas Masood

Azure函数未给出有效的Base-64字符串错误

  •  0
  • Raas Masood  · 技术社区  · 7 年前

    我有一个带有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字符、两个以上的填充字符或填充字符中的非法字符

    enter image description here

    我正在使用azure函数的V2。

    local.settings内容如下

    { “IsEncrypted”:错误, “AzureWebJobsStorage”:“UseDevelopmentStorage=true”, “函数\u工作者\u运行时”:“dotnet”, “MongoDBEndPoint”:“AccountEndpoint”= https://abc.documents.azure.com:10255;AccountKey=xxxxxxxxxxxxyyyyyyyyzzzzzzz “MongoDBName”:“haveThatDB” } }

    1 回复  |  直到 7 年前
        1
  •  1
  •   Mike Ubezzi    7 年前

    Azure Cosmos DB绑定仅支持与SQL API一起使用。对于所有其他azurecosmosdb API,您应该使用API的静态客户端从函数访问数据库,包括MongoDB API、Cassandra API、Gremlin API和Table API。 Supported APIs

    Azure Cosmos DB bindings for Azure Functions 2.x

    推荐文章