Using Cosmos DB table API from Azure function

Viewed 797

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?

1 Answers

We do not currently support talking to Table API from Azure Functions. It is on our road map.

Related