I am trying to connect to azure CosmosDB Table from function app.
I am getting the error
The remote server returned an error: (400) Bad Request.
When trying to perform the same connection from the sample c# project in visual studio, it works fine.
Code Snippet:
string connectionString = ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString;
CloudStorageAccount storageAccount = CreateStorageAccountFromConnectionString(connectionString);
CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
CloudTable table = tableClient.GetTableReference("People");
table.CreateIfNotExists();
The connection string is:
DefaultEndpointsProtocol=https;AccountName=digital-signature-db;AccountKey=XXX==;TableEndpoint=https://digital-signature-db.documents.azure.com
Full error stack:
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.ContinuationResultTaskFromTask
1.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.VoidTaskMethodInvoker2.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…
Please Advice.