调用Azure COSMOS DB表API函数(c#)形成Azure函数触发器(c#)

时间:2017-11-02 07:45:06

标签: azure azure-cosmosdb azure-functions

我想从Document DB的Azure Function触发器创建表。但它总是给出错误“远程服务器返回错误:(400)错误请求。”任何人都可以帮助解决这个问题吗?

    #r "Microsoft.Azure.Documents.Client"
using System.Diagnostics;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Table;
using Microsoft.Azure.Documents;
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System;
using  System.Net;
public static async Task Run(IReadOnlyList<Document> input, TraceWriter log)
{

string connectionString = "<connection string copied from portal>";
            try
            {
                CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);
                CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
                CloudTable table = tableClient.GetTableReference("testtable");
                bool f = table.CreateIfNotExists();
            }

            catch (StorageException e)
            {
                log.Info(e.InnerException.Message);
            }

}

function.json

{
    {
        "bindings": [{
            "type": "cosmosDBTrigger",
            "name": "input",
            "direction": "in",
            "leaseCollectionName": "leases",
            "connectionStringSetting": "personsTrigger_ConnectionString",
            "databaseName": "document-temp",
            "collectionName": "persons",
            "createLeaseCollectionIfNotExists": true
        }]
    }
}

0 个答案:

没有答案