简体   繁体   English

对于端点Webhook URL上的事件网格订阅,ARM部署失败

[英]ARM deployment failed for event grid subscription on endpoint webhook url

Using terraform and Azure ARm template , I am trying to create an azure event grid subscription on a function. 我正在使用terraform和Azure ARm模板,试图在一个函数上创建一个Azure事件网格订阅。

This the ARM using for the event grid subscription: 这是ARM用于事件网格订阅的方法:

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "eventGridTopicName": {
            "type": "string",
            "metadata": {
                "description": "The name of the Event Grid custom topic."
            }
        },
        "eventGridSubscriptionName": {
            "type": "string",
            "metadata": {
                "description": "The name of the Event Grid custom topic's subscription."
            }
        },
        "eventGridSubscriptionUrl": {
            "type": "string",
            "metadata": {
                "description": "The webhook URL to send the subscription events to. This URL must be valid and must be prepared to accept the Event Grid webhook URL challenge request. (RequestBin URLs are exempt from this requirement.)"
            }
        },
        "location": {
            "type": "string",
            "defaultValue": "[resourceGroup().location]",
            "metadata": {
                "description": "The location in which the Event Grid resources should be deployed."
            }
        }
    },
    "resources": [{
            "name": "[parameters('eventGridTopicName')]",
            "type": "Microsoft.EventGrid/topics",
            "location": "[parameters('location')]",
            "apiVersion": "2018-01-01"
        },
        {
            "name": "[concat(parameters('eventGridTopicName'), '/Microsoft.EventGrid/', parameters('eventGridSubscriptionName'))]",
            "type": "Microsoft.EventGrid/topics/providers/eventSubscriptions",
            "location": "[parameters('location')]",
            "apiVersion": "2018-01-01",
            "properties": {
                "destination": {
                    "endpointType": "WebHook",
                    "properties": {
                        "endpointUrl": "[parameters('eventGridSubscriptionUrl')]"
                    }
                },
                "filter": {
                    "includedEventTypes": [
                        "All"
                    ]
                }
            },
            "dependsOn": [
                "[parameters('eventGridTopicName')]"
            ]
        }
    ]
}

Following the documentation here in order to create the subscription, we have to recover a system key in order to create the complete webhook endpoint. 按照此处的文档创建订阅后,我们必须恢复系统密钥才能创建完整的webhook端点。 So following this post here , I have used an ARM template to recover the system key called evengrid_extension . 因此,在此发布本文之后 ,我使用了一个ARM模板来恢复名为evengrid_extension的系统密钥。

So everything goes well except during the arm deployment of the eventgrid subscription. 因此,除了在eventgrid订阅的手臂部署期间之外,其他一切都进行得很好。 I have this error: 我有这个错误:

Error waiting for deployment: Code="DeploymentFailed" Message="At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details." “等待部署时出错:Code =” DeploymentFailed“ Message =”至少一项资源部署操作失败。请列出部署操作以获取详细信息。请参阅https://aka.ms/arm-debug以获取使用详细信息。“ Details=[{"code":"Conflict","message":"{\\r\\n 详细= [{ “代码”: “冲突”, “消息”:“{\\ r \\ n
\\"status\\": \\"Failed\\",\\r\\n \\“状态\\”:\\“失败\\”,\\ r \\ n
\\"error\\": {\\r\\n \\"code\\": \\"ResourceDeploymentFailure\\",\\r\\n \\“ error \\”:{\\ r \\ n \\“ code \\”:\\“ ResourceDeploymentFailure \\”,\\ r \\ n
\\"message\\": \\"The resource operation completed with terminal provisioning state 'Failed'.\\",\\r\\n \\“ message \\”:\\“资源操作完成,终端供应状态为“ Failed”。\\”,\\ r \\ n
\\"details\\": [\\r\\n {\\r\\n \\“详细信息\\”:[\\ r \\ n {\\ r \\ n
\\"code\\": \\"Url validation\\",\\r\\n \\“代码\\”:\\“网址验证\\”,\\ r \\ n
\\"message\\": \\"The attempt to validate the provided endpoint https://myFunctionName.azurewebsites.net/runtime/webhooks/eventgrid failed. \\For more details, visit https: //aka.ms/esvalidation.\\"\\r\\n }\\r\\n ]\\r\\n }\\r\\n}"}] \\“消息\\”:\\“尝试验证提供的端点https://myFunctionName.azurewebsites.net/runtime/webhooks/eventgrid失败。\\有关更多详细信息,请访问https://aka.ms/esvalidation。\\” \\ r \\ n} \\ r \\ n] \\ r \\ n} \\ r \\ n}“}]

I check my code n terraform in order to be sure that I am using the right value for all parameters in this arm template and everything is ok. 我检查我的代码n terraform,以确保我为此手臂模板中的所有参数使用了正确的值,并且一切正常。 I have the right topic name, the right endpoint with all value filled in. So I don't understand what I am missing here. 我有正确的主题名称,正确的端点,所有值均已填写。因此,我不明白我在这里缺少什么。 I was wondering too if I am using the right system key. 我也想知道我是否使用了正确的系统密钥。 I know that there are a system key named durabletask_extension , and another one named eventgrid_extension . 我知道有一个名为耐用任务扩展名的系统密钥,还有一个名为eventgrid_extension的系统密钥。 But in fact I have tried with both and the same error occured. 但是实际上我已经尝试过两者,并且发生了相同的错误。


Update 更新

Just notice that the keys ie durabletask_extension and eventgrid_extension are both system keys. 只需注意,键(例如耐用任务扩展名事件网格扩展名)都是系统密钥。 So in my arm template to recover these works well and I recover the right system key by using only eventgrid_extension . 因此,在我的手臂模板中,恢复这些文件的效果很好,我仅使用eventgrid_extension恢复了正确的系统密钥。


Here my code for terraform: 这是我的terraform代码:

resource "azurerm_eventgrid_topic" "eventgrid_topic" {
  name                = "topicName"
  location            = var.main_location
  resource_group_name = azurerm_resource_group.name
}

resource "azurerm_template_deployment" "eventgrid_subscription" {
  name                = "EventGridSbscription"
  resource_group_name = azurerm_resource_group.environment.name

  template_body = file("./arm/event-grid-subscription.json")

  parameters = {
    eventGridTopicName = "${azurerm_eventgrid_topic.eventgrid_topic.name}"
    eventGridSubscriptionName = "eventgrid-myFunctionName"
    eventGridSubscriptionUrl = "https://${azurerm_function_app.function.name}.azurewebsites.net/runtime/webhooks/eventgrid?functionName=${azurerm_function_app.function.name}&code=${lookup(azurerm_template_deployment.function_key.outputs, "systemKey")}"
    location = var.main_location
  }

  deployment_mode = "Incremental"

  depends_on = [
    azurerm_template_deployment.function_key
  ]
}

So I do not understand why my susbription deployment failed, or what I am missing in order to automate this settings with terraform. 因此,我不明白为什么我的暂存部署失败,或者为了用terraform自动化此设置而缺少了什么。

Following the doc here I understand too that: 遵循这里的文档我也明白:

If you don't have access to the application code (for example, if you're using a third-party service that supports webhooks), you can use the manual handshake mechanism. 如果您无权访问应用程序代码(例如,如果您使用的是支持Webhooks的第三方服务),则可以使用手动握手机制。 Make sure you're using the 2018-05-01-preview API version or later (install Event Grid Azure CLI extension) to receive the validationUrl in the validation event. 确保您使用的是2018-05-01-preview API版本或更高版本(安装Event Grid Azure CLI扩展)以在验证事件中接收validationUrl。 To complete the manual validation handshake, get the value of the validationUrl property and visit that URL in your web browser. 要完成手动验证握手,请获取validationUrl属性的值,然后在网络浏览器中访问该URL。 If validation is successful, you should see a message in your web browser that validation is successful. 如果验证成功,您应该在Web浏览器中看到一条消息,表明验证成功。 You'll see that event subscription's provisioningState is "Succeeded". 您将看到事件订阅的ProvisioningState为“成功”。

So, there is a way to make a validation using terraform or another way to automate this validation ? 因此,有一种方法可以使用terraform进行验证,或者可以通过另一种方法来自动执行此验证?

The template is right, you just misunderstand something in the eventGridSubscriptionUrl . 该模板是正确的,您只是误解了eventGridSubscriptionUrl中的eventGridSubscriptionUrl Take a look at the URL . 看一下URL The URL shows like this: URL显示如下:

Version 2.x runtime 2.x版运行时

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

Version 1.x runtime 1.x版运行时

https://{functionappname}.azurewebsites.net/admin/extensions/EventGridExtensionConfig?functionName={functionname}&code={systemkey}

The functionappname is what you set as the value azurerm_function_app.function.name , but functionname is not. functionappname是您设置为值azurerm_function_app.function.name的值,而functionname不是。

You get the existing function name through the Azure REST API Web Apps - Get Function . 您可以通过Azure REST API Web Apps-Get Function获得现有的函数名称。

And in Terraform, it seems there is no function resource in the function app for you to create. 在Terraform中,似乎函数应用程序中没有可供您创建的函数资源。 But you can also use the template to create the function and output the function name. 但是您也可以使用模板创建函数并输出函数名称。 Then you can set it in the URL. 然后,您可以在URL中进行设置。 You can get more details about function in the Azure Template here and the function name shows in the property. 您可以在此处的Azure模板中获得有关函数的更多详细信息,函数名称显示在属性中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 获取 ARM 中函数应用程序的 Webhook url 以用于事件网格订阅 - Get Webhook url of a Function App in ARM to use for Event Grid Subscription 使用 arm-template 使用“deliveryAttributeMappings”创建“WEBHOOK”类型的事件网格主题订阅时出错 - Error creating Event grid topic subscription of type 'WEBHOOK' with 'deliveryAttributeMappings' static Header using arm-template Azure 函数事件网格订阅自定义主题的 ARM 模板部署失败 - ARM template deployment fails for Azure Function Event Grid Subscription to custom topic 无法为事件网格创建 Webhook 订阅 - Unable to create Webhook Subscription for Event-Grid 无法将Webhook订阅添加到Azure事件网格 - Not able to add webhook subscription to the Azure Event Grid 使用 ARM 创建事件网格订阅以收集订阅的事件 - Use ARM to create an event grid subscription to collect events for a subscription 如何在 ARM 模板中添加 AzureFunction 作为事件订阅端点? - How to add AzureFunction as Event Subscription Endpoint in ARM Template? 在 ARM 中使用事件中心主题类型创建事件网格订阅 - Create Event Grid Subscription with Event Hub Topic type in ARM Azure 事件网格 - Webhook 订阅身份验证和 DDOS 保护 - Azure Event Grid - Webhook subscription authentication and DDOS protection 如何为 Azure 事件网格创建 Webhook 订阅 - How to create a Webhook subscription for Azure Event-Grid
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM