"在配置期间无法更新资源"从ARM模板部署Event Grid Subscription时出错

时间:2018-04-16 16:48:14

标签: azure arm-template azure-eventgrid

在部署Azure Event Grid订阅时,我们开始收到"资源在配置期间无法更新"错误从上周开始,无处不在,ARM模板已经工作了好几周没有变化。

持续部署ARM模板基本上是部署Azure功能应用程序的最新AppSettings以及事件网格主题订阅。以下是CD中的重要步骤,它在执行ARM模板的第一步失败:

Continous Deployment Steps

VSTS中持续部署的错误消息:

2018-04-16T15:42:12.8544806Z There were errors in your deployment. Error code: DeploymentFailed.
2018-04-16T15:42:12.8544806Z ##[error]At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details.
2018-04-16T15:42:12.8544806Z ##[error]Details:
2018-04-16T15:42:12.8544806Z ##[error]Conflict: {
  "status": "Failed",
  "error": {
    "code": "ResourceDeploymentFailure",
    "message": "The resource operation completed with terminal provisioning state 'Failed'.",
    "details": [
      {
        "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.",
        "details": [
          {
            "code": "BadRequest",
            "message": "{\r\n  \"error\": {\r\n    \"code\": \"InvalidRequest\",\r\n    \"message\": \"Resource cannot be updated during provisioning\"\r\n  }\r\n}"
          }
        ]
      }
    ]
  }
} undefined
2018-04-16T15:42:12.8544806Z ##[error]Task failed while creating or updating the template deployment.

在查看Azure门户中的事件网格活动日志时,我发现了以下信息,确认订阅失败:

{
  "authorization": {
    "action": "Microsoft.EventGrid/eventSubscriptions/write",
    "scope": "[REMOVED]"
  },
  "caller": "a11d0bff-196e-4967-a4be-7fa0c095d39f",
  "channels": "Operation",
  "claims": {
    "aud": "[REMOVED]"
  },
  "correlationId": "a7be5495-e9b8-47fd-a2be-9aa30b9ec54a",
  "description": "",
  "eventDataId": "005b7a10-b0d1-4281-9e44-26f33e4a3e39",
  "eventName": {
    "value": "EndRequest",
    "localizedValue": "End request"
  },
  "category": {
    "value": "Administrative",
    "localizedValue": "Administrative"
  },
  "eventTimestamp": "2018-04-16T16:26:31.5821162Z",
  "id": "[REMOVED]",
  "level": "Error",
  "operationId": "fea43c00-d46e-49d4-8c97-d78a9951aaaa",
  "operationName": {
    "value": "Microsoft.EventGrid/eventSubscriptions/write",
    "localizedValue": "Microsoft.EventGrid/eventSubscriptions/write"
  },
  "resourceGroupName": "[REMOVED]",
  "resourceProviderName": {
    "value": "Microsoft.EventGrid",
    "localizedValue": "Microsoft.EventGrid"
  },
  "resourceType": {
    "value": "Microsoft.EventGrid/eventSubscriptions",
    "localizedValue": "Microsoft.EventGrid/eventSubscriptions"
  },
  "resourceId": "[REMOVED]",
  "status": {
    "value": "Failed",
    "localizedValue": "Failed"
  },
  "subStatus": {
    "value": "",
    "localizedValue": ""
  },
  "submissionTimestamp": "2018-04-16T16:26:55.0807594Z",
  "subscriptionId": "[REMOVED]",
  "properties": {
    "statusCode": "BadRequest",
    "statusMessage": "{\"error\":{\"code\":\"InvalidRequest\",\"message\":\"Resource cannot be updated during provisioning\"}}",
    "serviceRequestId": "05c4b3e5-692a-4669-b8b4-c00a3a9cbd88"
  },
  "relatedEvents": [

  ]
}

从事件网格订阅的ARM模板中提取:

            {
        "apiVersion": "2017-05-10",
        "name": "nested-shared-rg",
        "type": "Microsoft.Resources/deployments",
        "resourceGroup": "[variables('globalSharedResourceGroupName')]",
        "properties": {
            "mode": "Incremental",
            "template": {
                "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
                "contentVersion": "1.0.0.0",
                "parameters": {},
                "variables": {},
                "resources": [
                    {
                        "name": "[concat(variables('notificationTopicName'), '/Microsoft.EventGrid/', variables('notificationTopicSubscriptionName'))]",
                        "type": "Microsoft.EventGrid/topics/providers/eventSubscriptions",
                        "apiVersion": "2017-06-15-preview",
                        "tags": {
                            "version": "[parameters('templateVersion')]",
                            "fullVersion": "[parameters('templateFullVersion')]",
                            "scope": "[parameters('webAppFctName')]",
                            "environment": "[parameters('environmentName')]",
                            "displayName": "Event Grid Subscription"
                        },
                        "properties": {
                            "destination": {
                                "endpointType": "WebHook",
                                "properties": {
                                    "endpointUrl": "[concat('https://', variables('webAppName') ,'.azurewebsites.net', variables('notificationEndPointPath'))]"
                                }
                            },
                            "filter": {
                                "includedEventTypes": [ "All" ],
                                "subjectBeginsWith": "",
                                "subjectEndsWith": "",
                                "subjectIsCaseSensitive": false
                            },
                            "labels": [ "" ]
                        }
                    }
                ],
                "outputs": {
                    "resourceGroupOutput": {
                        "type": "object",
                        "value": "[resourceGroup()]"
                    }
                }
            },
            "parameters": {}
        }
    }

谢谢! 西蒙

1 个答案:

答案 0 :(得分:0)

在本节中:

https://docs.microsoft.com/en-us/azure/data-factory/continuous-integration-deployment#sample-script-to-stop-and-restart-triggers-and-clean-up

如果您有很多触发器(我们有 36 个基于事件的触发器),此行似乎会导致间歇性错误。 Start-AzDataFactoryV2Trigger -ResourceGroupName $ResourceGroupName -DataFactoryName $DataFactoryName -Name $_ -Force

通过添加一个短暂的延迟(5 秒),似乎可以避免错误。即 foreach 中的“Start-Sleep -s 5”。