使用Az CLI创建EventGrid订阅

时间:2020-07-14 10:27:43

标签: powershell azure-cli azure-eventgrid

我正在使用以下命令创建事件订阅:

az eventgrid event-subscription create --source-resource-id "/subscriptions/mysubscription/resourceGroups/myresourcegroup/providers/Microsoft.EventGrid/topics/mytopic" --name "new-subscription" --endpoint-type "webhook" --endpoint "https://myfunctionapp.azurewebsites.net/runtime/webhooks/EventGrid?functionName=myfunction&code=mymasterkey"

但是,总的来说,我收到此错误消息:

Deployment failed. Correlation ID: 154239e9-9992-4c4c-a991-83b88cc9bd91. Webhook validation handshake failed for https://myfunctionapp.azurewebsites.net/runtime/webhooks/EventGrid. Http POST request failed with response code Unknown. For troublehooting, visit https://aka.ms/esvalidation. Activity id:a9a4804c-927f-4bc4-8f0b-99d80eed08a3, timestamp: 7/14/2020 10:20:28 AM (UTC).

怎么了?

1 个答案:

答案 0 :(得分:1)

根据该错误,您的函数网址似乎不正确,并且无法完成验证。函数URL应该类似于setCustomSize(){ this.gridColumnApi.setColumnWidth(key, width) } 。您可以通过Azure门户获取它。有关更多详细信息,请参阅document

例如

https://{functionappname}.azurewebsites.net/runtime/webhooks/eventgrid?functionName={functionname}&code={systemkey}

enter image description here

此外,由于您使用Azure函数事件穿越触发器,因此可以直接使用函数应用程序资源ID作为终结点。有关更多详细信息,请参阅documenthere

例如

az eventgrid event-subscription create  -n "test" --source-resource-id "<my topic resource id>"  --endpoint "https://myfunctionapp.azurewebsites.net/runtime/webhooks/EventGrid?functionName=myfunction&code=mymasterkey"

enter image description here enter image description here