I'm trying to use Cosmos DB table API from an Azure function. Using the local.settings.json file I'm able to read the connection string and parse it successfully as I'm used to:
local.settings.json:
{
"IsEncrypted": false,
"Values": {
"ConnectionString": "DefaultEndpointsProtocol=https;AccountName=MYSTORAGEACCOUNT;AccountKey=AUTHKEY;TableEndpoint=https://COSMODB.documents.azure.com"
}
}
Initiating connection:
var storageAccount = CloudStorageAccount.Parse(ConnectionString);
var tableClient = storageAccount.CreateCloudTableClient();
var table = tableClient.GetTableReference("users");
The problem comes after this when I call
table.CreateIfNotExists();
This returns a http error 400 with the inner exception also being a http error 400 and no further explanation. It seems looking at the Cosmos DB sample that I need to set some additional settings, probably atleast this:
<configuration>
<appSettings>
<!--Table creation options -->
<add key="TableThroughput" value="700"/>
</appSettings>
</configuration>
How do I go about setting these either in code or in the local.settings.json file so I can use them in the Azure function? Or am I heading the wrong direction?
Values
. Have you tried to use Table binding instead? (I haven't, so not sure if it works with Cosmos) - Mikhail Shilkovtrace.LogInformation($"Assembly: {table.GetType().Assembly.FullName}");
to your code and see what assembly your table is coming from? - brettsam