gpt4 book ai didi

c# - 尝试将 Azure Function App 连接到 Azure Cosmos DB 表时出现错误 400

转载 作者:行者123 更新时间:2023-12-03 04:22:33 25 4
gpt4 key购买 nike

我正在尝试从函数应用连接到 azure CosmosDB 表。

我收到错误

The remote server returned an error: (400) Bad Request.

当尝试从 Visual Studio 中的示例 C# 项目执行相同的连接时,效果很好。

代码片段:

string connectionString = ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString;           
CloudStorageAccount storageAccount = CreateStorageAccountFromConnectionString(connectionString);

CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
CloudTable table = tableClient.GetTableReference("People");

table.CreateIfNotExists();

连接字符串是:

DefaultEndpointsProtocol=https;AccountName=digital-signature-db;AccountKey=XXX==;TableEndpoint=https://digital-signature-db.documents.azure.com

完整错误堆栈:

Exception while executing function: Functions.SignPDF Microsoft.Azure.WebJobs.Host.FunctionInvocationException : Exception while executing function: Functions.SignPDF ---> System.AggregateException : One or more errors occurred. ---> The remote server returned an error: (400) Bad Request. ---> The remote server returned an error: (400) Bad Request. at Microsoft.Azure.WebJobs.Script.Description.DotNetFunctionInvoker.GetTaskResult(Task task) at C:\projects\azure-webjobs-sdk-script\src\WebJobs.Script\Description\DotNet\DotNetFunctionInvoker.cs : 453 at Microsoft.Azure.WebJobs.Script.Description.DotNetFunctionInvoker.<>c.b__26_0(Task t) at C:\projects\azure-webjobs-sdk-script\src\WebJobs.Script\Description\DotNet\DotNetFunctionInvoker.cs : 276 at System.Threading.Tasks.ContinuationResultTaskFromTask1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
at async Microsoft.Azure.WebJobs.Script.Description.DotNetFunctionInvoker.InvokeCore(Object[] parameters,FunctionInvocationContext context) at C:\projects\azure-webjobs-sdk-script\src\WebJobs.Script\Description\DotNet\DotNetFunctionInvoker.cs : 276
at async Microsoft.Azure.WebJobs.Script.Description.FunctionInvokerBase.Invoke(Object[] parameters) at C:\projects\azure-webjobs-sdk-script\src\WebJobs.Script\Description\FunctionInvokerBase.cs : 90
at async Microsoft.Azure.WebJobs.Host.Executors.VoidTaskMethodInvoker
2.InvokeAsync[TReflected,TReturnType](TReflected instance,Object[] arguments) at async Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker`2.InvokeAsync[TReflected,TReturnValue](Object instance,Object[] arguments) at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.InvokeAsync(IFunctionInvoker invoker,ParameterHelper parameterHelper,CancellationTokenSource timeoutTokenSource,CancellationTokenSource functionCancellationTokenSource,Boolean throwOnTimeout,TimeSpan timerInterval,IFunctionInstance instance) at async Microsoft.Azure.WebJobs.Host.Ex…

请多多指教。

最佳答案

CreateIfNotExists 调用需要引用WindowsAzure.Storage-PremiumTable。在控制台应用中引用时,它将用版本 1.0.9.1 替换 Microsoft.WindowsAzure.Storage.dll。 Azure Functions 目前不支持此功能。请向 CosmosDB 团队提出有关此问题的问题。我们在跟踪此问题时遇到问题 https://github.com/Azure/azure-webjobs-sdk-script/issues/2026#issuecomment-343910660

关于c# - 尝试将 Azure Function App 连接到 Azure Cosmos DB 表时出现错误 400,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47271675/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com