4

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?

5
  • To add an app setting, just add another node under Values. Have you tried to use Table binding instead? (I haven't, so not sure if it works with Cosmos) Commented Sep 17, 2017 at 15:28
  • I tried that but somehow they don't work out of the box like they do in the sample app (github.com/Azure-Samples/…) with the App.config. Everything works fine if I use regular table storage with a connection string but it seems I'm missing something regarding the Cosmos table API. I'll have a look into table bindings for Cosmos. Commented Sep 17, 2017 at 15:33
  • Try using the Premium Storage SDK, and not the Azure Storage SDK. Commented Sep 18, 2017 at 10:15
  • This error comes from Premium Storage SDK. I was able to get the bindings working for both graph API and document DB using the function.json definitions but still no luck with the table API. Commented Sep 18, 2017 at 13:28
  • How are you wiring up the Premium Storage SDK? I'm wondering if perhaps you're still using the Azure Storage SDK b/c that's what's being referenced by the Functions host. Can you add a line like: trace.LogInformation($"Assembly: {table.GetType().Assembly.FullName}"); to your code and see what assembly your table is coming from? Commented Sep 18, 2017 at 15:41

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.