我可以在azure函数绑定模板中连接值吗?

时间:2018-03-16 20:06:48

标签: azure binding azure-functions

是否可以将两个URL参数值连接起来传递给表存储模板绑定?

像...一样的东西。

[FunctionName("GetSomeValue")]
public static IActionResult Get
(
    [HttpTrigger(AuthorizationLevel.Function, "get", Route = ROUTE + "/{somevalue}/{someOtherValue}")]HttpRequest request,
    string somevalue,
    string someOtherValue,
    [Table(
        TABLE_NAME,
        ALL_HOSPITAL_PARTITION_KEY, 
        "{somevalue + '|' + someOtherValue}", //<--- This isn't acceptable
        Connection = "SomeValuesConnectionStringKey")]
        TableStoreDAO<SomeValueDAO> tableStoreRecord,
    ExecutionContext context,
    TraceWriter log
)

以下是错误:

[3/16/2018 8:05:16 PM] A ScriptHost error has occurred
[3/16/2018 8:05:16 PM] Microsoft.Azure.WebJobs.Host: Error indexing method 'SomeValueService.Get'. Microsoft.Azure.WebJobs.Host: Invalid template '{somevalue + '|' + someOtherValue}'. Invalid template expression 'somevalue + '|' + someOtherValue.

我似乎无法找到关于模板的任何文档...任何对此的引用都会很棒。

1 个答案:

答案 0 :(得分:0)

通过简单猜测可能允许的内容找到答案。这对我有用:{somevalue}|{someOtherValue}

完整示例:

[FunctionName("GetSomeValue")]
public static IActionResult Get
(
    [HttpTrigger(AuthorizationLevel.Function, "get", Route = ROUTE + "/{somevalue}/{someOtherValue}")]HttpRequest request,
    string somevalue,
    string someOtherValue,
    [Table(
        TABLE_NAME,
        ALL_HOSPITAL_PARTITION_KEY, 
        "{somevalue}|{someOtherValue}",
        Connection = "SomeValuesConnectionStringKey")]
        TableStoreDAO<SomeValueDAO> tableStoreRecord,
    ExecutionContext context,
    TraceWriter log
)