Azure 将云表作为输入绑定传递

Azure 将云表作为输入绑定传递,azure,azure-functions,Azure,Azure Functions,我正在尝试创建一个azure函数,它将azure表作为存储,然后我在函数中读取它。当我指定以下签名时,我能够运行该函数 public static async System.Threading.Tasks.Task RunAsync([TimerTrigger("0 */1 * * * *")]TimerInfo myTimer, [Table("CovidUpdateTable")]CloudTable ServiceFormTable, [Blob("outcontainer/{Date

我正在尝试创建一个azure函数,它将azure表作为存储,然后我在函数中读取它。当我指定以下签名时,我能够运行该函数

  public static async System.Threading.Tasks.Task RunAsync([TimerTrigger("0 */1 * * * *")]TimerInfo myTimer, [Table("CovidUpdateTable")]CloudTable ServiceFormTable, [Blob("outcontainer/{DateTime}", FileAccess.Write)] Stream outputBlob, ILogger log)
在这里,我必须在table属性中指定表名,即使我已经在绑定配置中指定了它,如下所示

{
      "type": "table",
      "name": "ServiceFormTable",
      "tableName": "CovidUpdateTable",
      "take": 50,
      "connection": "AzureWebJobsStorage",
      "direction": "in"
    }

在portalc#脚本中,我可以直接绑定到CloudTable,但在visualstudio中,如果我删除table属性并仅使用CloudTable,它会抛出一个错误。当我必须在table属性中指定名称时,我不确定此配置中tablename的用途。

当我们在Azure portal中创建函数时,它将为我们创建一个c#脚本函数(csx文件)并生成function.json文件。函数将以常染色体方式从function.json文件中读取配置。因此,我们可以直接在文件中配置Bing,而不需要在代码中进行配置。但当我们在Visual Studio中创建函数时,它将创建c#函数(cs文件),而不会为我们生成function.json文件。并且函数不会以常染色体方式从function.json文件中读取配置。因此,我们需要使用属性配置这些设置。有关更多详细信息,请参阅


使现代化 如果要使用local.settings.json中的绑定属性,请参考以下步骤

  • local.settings.json

  • 有关更多详细信息,请参阅

    谢谢Jim,这是否意味着没有必要在local.settings.json中添加绑定属性。我认为function.json中的绑定可以放在那里。
    {
      "IsEncrypted": false,
      "Values": {
        "AzureWebJobsStorage": "",
        "FUNCTIONS_WORKER_RUNTIME": "dotnet",
        "TableConnection": "<your azure table connection string>",
        "Tablename": "<your table name>"
      }
    
    }
    
     public static async Task<IActionResult> Run(
                [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
                [Table("%Tablename%",Connection = "TableConnection")]CloudTable cloudTable,
                ILogger log)
            {
                
                log.LogInformation("C# HTTP trigger function processed a request.");
                log.LogInformation(cloudTable.Name);
                var query = new TableQuery<DynamicTableEntity>();
    
                foreach (var entity in
                    await cloudTable.ExecuteQuerySegmentedAsync(query, null))
                {
                    log.LogInformation(
                        $"{entity.PartitionKey}\t{entity.RowKey}\t{entity.Timestamp}");
                }
    ....
    }