我正在开发一个Azure逻辑应用程序来处理Azure Key Vault上的几个事件(即将到期,过期)的通知。我的设置涉及到每个密钥库的事件网格,所有事件都发送到同一个逻辑应用程序。
当事件网格将事件发送到逻辑应用程序时,它们以事件数组的形式出现。我试图在我的Logic应用程序中使用'For each'循环来单独处理这些事件。以下是我的Logic应用程序的相关部分:
我有一个“当收到HTTP请求时”触发器,然后是一个“For each”循环,其中triggerBody()作为输入,在循环中,我有一个“发送电子邮件(V2)”动作。在'Send an email(V2)'操作中,我尝试使用items()函数访问每个事件的属性,如下所示:
Event Type: @{items()?['eventType']}
Key Vault Name: @{items()?['data']?['VaultName']}
Object Type: @{items()?['data']?['ObjectType']}
Object Name: @{items()?['data']?['ObjectName']}
Expiry Date: @{items()?['data']?['EXP']}
但是当我尝试保存Logic应用程序时,我收到以下错误消息:Failed to save logic app. The template validation failed: 'The template action 'Send_an_email_(V2)' at line '1' and column '1679' is not valid: "The template language function 'items' must have at least one parameter.".'.
我已经查看了文档,并了解到items()在'For each'循环中使用时不需要参数,因为它会自动引用'For each'循环遍历的数组的当前项。
我做错了什么?如何设置我的Logic应用程序,使用“For each”循环和items()函数分别正确处理每个事件?
下面是我的schema输入:
{
"schema": {
"properties": {
"$schema": {
"type": "string"
},
"properties": {
"properties": {
"data": {
"properties": {
"properties": {
"properties": {
"EXP": {
"properties": {
"type": {
"type": "string"
}
},
"type": "object"
},
"Id": {
"properties": {
"type": {
"type": "string"
}
},
"type": "object"
},
"NBF": {
"properties": {
"type": {
"type": "string"
}
},
"type": "object"
},
"ObjectName": {
"properties": {
"type": {
"type": "string"
}
},
"type": "object"
},
"ObjectType": {
"properties": {
"type": {
"type": "string"
}
},
"type": "object"
},
"VaultName": {
"properties": {
"type": {
"type": "string"
}
},
"type": "object"
},
"Version": {
"properties": {
"type": {
"type": "string"
}
},
"type": "object"
}
},
"type": "object"
},
"required": {
"items": {
"type": "string"
},
"type": "array"
},
"type": {
"type": "string"
}
},
"type": "object"
},
"dataVersion": {
"properties": {
"type": {
"type": "string"
}
},
"type": "object"
},
"eventTime": {
"properties": {
"type": {
"type": "string"
}
},
"type": "object"
},
"eventType": {
"properties": {
"type": {
"type": "string"
}
},
"type": "object"
},
"id": {
"properties": {
"type": {
"type": "string"
}
},
"type": "object"
},
"metadataVersion": {
"properties": {
"type": {
"type": "string"
}
},
"type": "object"
},
"subject": {
"properties": {
"type": {
"type": "string"
}
},
"type": "object"
},
"topic": {
"properties": {
"type": {
"type": "string"
}
},
"type": "object"
}
},
"type": "object"
},
"required": {
"items": {
"type": "string"
},
"type": "array"
},
"type": {
"type": "string"
}
},
"type": "object"
}
}
输出示例:
[
{
"id": "5a",
"topic": "/subscriptions/8",
"subject": "kv",
"eventType": "Microsoft.KeyVault.SecretNearExpiry",
"data": {
"Id": "https://kv",
"VaultName": "kv-v",
"ObjectType": "Secret",
"ObjectName": "kv",
"Version": "",
"NBF": null,
"EXP": "2023-06-13T00:00:00Z"
},
"dataVersion": "1",
"metadataVersion": "1",
"eventTime": "2023-06-12T00:00:00Z"
}
]
1条答案
按热度按时间slmsl1lt1#
我尝试通过对2个密钥库使用一个逻辑应用程序,并为每个密钥库使用单独的事件网格来再现该问题,订阅多个事件类型-
这两个密钥存储库向单个逻辑应用发布事件-
在“从前面的步骤中选择一个输出”中,我取
triggerBody()
。请求正文-
我得到的输出是-
我收到所有订阅事件类型的电子邮件通知-