azure-data-factory-2 - ADF v2 - 如何向 Teams 发送错误消息?
问题描述
我使用此模板向 Teams 频道发送通知。
但我发现,它不能发送错误信息。因为它无法将字符串解析为 json。
Operation on target Call Teams Webhook failed: The function 'json' parameter is not valid. The provided value '{ "@type": "MessageCard", "@context": "http://schema.org/extensions", "themeColor": "0076D7", "summary": "Pipeline status alert message", "sections": [ { "activityTitle": "Pipeline alert", "facts": [ { "name": "Pipeline RunId:", "value": "8b5b8400-346f-425a-8a64-f63bcf993370" }, { "name": "Activity name:", "value": "[CosmosDB Backup] Backup Data Error" }, { "name": "Activity status:", "value": "Failed" }, { "name": "Execution duration (s):", "value": "1" }, { "name": "Message", "value": "{ "message": "Different
...
annot be parsed: 'After parsing a value an unexpected character was encountered: m. Path 'sections[0].facts[4].value', line 29, position 3
想到的唯一方法是“通过{}剪切字符串”
解决方案
- 将字符串剪断
{}
@substring(
activity('xxx').error.message,
indexof(activity('xxx').error.message,'{'),
add(
sub(lastindexof(activity('xxx').error.message,'}'),indexof(activity('xxx').error.message,'{'))
,1)
)
@json()
上面的结果- 得到你想要的价值
完整代码:
@json(substring(
activity('xxx').error.message,
indexof(activity('xxx').error.message,'{'),
add(sub(lastindexof(activity('xxx').error.message,'}'),indexof(activity('xxx').error.message,'{')),1)
)).message
我想要 JSON 对象的消息。
推荐阅读
- php - 当我尝试在 symfony 4 中对我的密码进行哈希处理时,我得到了什么错误
- go - 在circle ci中使用go mod获取私人回购
- python - Autospec 模拟没有正确保留签名?
- java - 修改有效的 AWS 联合用户策略/联合令牌 (AWSJavaSDK)
- sql - 在 SAS 中将表从 SQL Server 复制到 Oracle - SQL Server 中的列名太长
- ios - 在 iOS 中,在纯 C 中,这是获取本地文件路径的方法吗?
- java - 如何删除数组中的“null”元素?
- python - 通过模块名称和严重性记录到不同的位置
- c# - 如何映射字典类型的属性
使用流利的映射 - mysql - GROUP_CONCAT 不同的日期和相应的值(绘制图表)