When I interact with CosmosDB from Azure Cloud Service I am getting 'Forbidden' on each call that deals with data in the table. Even creating a table is 'Forbidden' from inside the service. The same code works perfectly from the WinForms application.
Here is the code I am using on my desktop WinForms app (works perfectly) and fails with 'Forbidden' inside Cloud Service even if I run it through VS Debugger on my machine:
using Microsoft.Azure.Cosmos.Table;
...
string connectionString = "DefaultEndpointsProtocol=https;AccountName=xxx;AccountKey=yyy;TableEndpoint=https://xxx.table.cosmos.azure.com:443/;";
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);
TableClientConfiguration config = new TableClientConfiguration();
config.UseRestExecutorForCosmosEndpoint = true;
CloudTableClient tableClient = storageAccount.CreateCloudTableClient(config);
// Create the table if it doesn't exist
CloudTable tbl1 = tableClient.GetTableReference("table1");
tbl1.CreateIfNotExists();
CloudTable tbl2 = tableClient.GetTableReference("table2");
tbl2.CreateIfNotExists();
Running on Azure inside the service, 'CreateIfNotExists' call will fail with 'Forbidden'. Is there something I have to specify on the database/table itself or am I doing something wrong?
Thanks
I got it working. You can access CosmosDB only using TLS 1.2.
After I added this line on the Start of the service it started working just fine.
Sorry for the confusion.