azure-devops - 无法解析模板语言表达式'encodeURIComponent([parameters('table_storage_name')])'
问题描述
嘿,我正在为一个逻辑应用程序进行 CI/CD 部署,我有一个存储一些数据的表存储,我有两个用于测试和生产环境的表存储。我在 ARM 模板中创建了一个名为 *table_storage_name 的参数:
"parameters": {
// ....
"connections_azuretables_1_externalid": {
"defaultValue": "/subscriptions/e5..../resourceGroups/myrg.../providers/Microsoft.Web/connections/azuretables-1",
"type": "String"
},
"table_storage_name": {
"defaultValue": "testdevops",
"type": "String"
}
}
当我在template.json文件中引用参数时,错误来自:
// ...
"Insert_Entity": {
"runAfter": {
"Initialize_variable": [
"Succeeded"
]
},
"type": "ApiConnection",
"inputs": {
"body": {
"PartitionKey": "@body('Parse_JSON')?['name']",
"RowKey": "@body('Parse_JSON')?['last']"
},
"host": {
"connection": {
"name": "@parameters('$connections')['azuretables_1']['connectionId']"
}
},
"method": "post",
// problem occur after this line
"path": "/Tables/@{encodeURIComponent('[parameters('table_storage_name')]')}/entities"
}
}
但得到这个错误:
InvalidTemplate:模板验证失败:“第 1 行和第 582 列的模板操作 'Insert_Entity' 无效:“无法解析模板语言表达式 'encodeURIComponent([parameters('table_storage_name')])':预期令牌'标识符'和实际的'LeftSquareBracket'。“。”。
我尝试用反斜杠转义引号,例如:encodeURIComponent(\'[parameters('table_storage_name')]\')
或者encodeURIComponent('[parameters(''table_storage_name'')]')
但所有这些都会引发错误。如何在 ARM 模板中引用 encodeURIComponent 中的参数?
解决方案
正如评论中所讨论的那样。学分:@marone
"path": "/Tables/@{encodeURIComponent(parameters('table_storage_name'))}/entities"
推荐阅读
- mqtt - 无法确定为什么 inputs.mqtt_consumer 断开连接并且不通过 telegraf 向 influxdb 发送数据
- r - 从 Shiny 中的多个对齐图中单击位置
- sql - 我正在尝试从我已经在 Oracle Live SQL 中创建的 2 个不同表中查看 4 列
- python-3.x - 即使使用 WebDriverWait,Selenium Webdriver 元素也会返回 None
- python - docopt 不应用默认值
- flutter - 是否有安装 import 'package:speech_to_text/speech_to_text.dart' 的解决方案;
- python - 获取 AttributeError:“Tensor”对象在保存 TensorFlow 模型时没有属性“log_prob”
- c# - 将 2 个 observablecollections 中的匹配值组合成第 3 个 [WPF]
- machine-learning - 为什么 SHERPA 仪表板可视化显示为空白?
- .net - 消息队列完成后如何回复?