gpt4 book ai didi

Azure Bicep - 部署失败(冲突)对此资源或依赖资源的另一项操作正在进行中 (AnotherOperationInProgress)

转载 作者:行者123 更新时间:2023-12-02 07:38:01 26 4
gpt4 key购买 nike

我是二头肌新手,正在尝试使用模块创建 VNet 和子网。我有以下两个模块

vnet.bicep

param name string
param location string
param addressPrefixes array
param tags object

resource virtualNetwork 'Microsoft.Network/virtualNetworks@2019-11-01' = {
name: name
location: location
properties: {
addressSpace: {
addressPrefixes: addressPrefixes
}
}

tags: tags
}

子网.bicep

param parentVnetName string
param name string
param addressPrefix string

resource parentVnet 'Microsoft.Network/virtualNetworks@2020-11-01' existing = {
name: parentVnetName
}

resource subnet 'Microsoft.Network/virtualNetworks/subnets@2021-08-01' = {
name: name
parent: parentVnet
properties: {
addressPrefix: addressPrefix
}
}

我正在尝试使用以下配置来创建 vnet 和多个子网。

param location string = 'uksouth'

param vnet object = {
name: 'vnet'
addressPrefixes: [
'10.0.0.0/16'
]
subnets: [
{
name: 'subnet1'
addressPrefix: '10.0.1.0/24'
}
{
name: 'subnet2'
addressPrefix: '10.0.2.0/24'
}
]
}

targetScope = 'subscription'

resource rg 'Microsoft.Resources/resourceGroups@2021-01-01' = {
name: 'rg'
location: location
tags: {}
}

module vnetsym 'modules/vnet.bicep' = {
scope: rg
name: vnet.name
params: {
name: vnet.name
location: location
addressPrefixes: vnet.addressPrefixes
tags: {}
}
}

module subnetsym 'modules/subnet.bicep' = [for subnet in vnet.subnets: {
scope: rg
name: subnet.name
params: {
name: subnet.name
addressPrefix: subnet.addressPrefix
parentVnetName: vnet.name
}
dependsOn: [
vnetsym
]
}]

但是,二头肌似乎无法解决依赖关系并引发以下错误。除此部署外,没有其他操作正在进行中。为什么模块依赖关系在这种情况下不起作用以及如何修复它?

{"status":"Failed","error":{"code":"DeploymentFailed","message":"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.","details":[{"code":"Conflict","message":"{\r\n  \"status\": \"Failed\",\r\n  \"error\": {\r\n    \"code\": \"ResourceDeploymentFailure\",\r\n    \"message\": \"The resource operation completed with terminal provisioning state 'Failed'.\",\r\n    \"details\": [\r\n      {\r\n        \"code\": \"DeploymentFailed\",\r\n        \"message\": \"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.\",\r\n        \"details\": [\r\n          {\r\n            \"code\": \"Conflict\",\r\n            \"message\": \"{\\r\\n  \\\"error\\\": {\\r\\n 
\\\"code\\\": \\\"AnotherOperationInProgress\\\",\\r\\n \\\"message\\\": \\\"Another operation on this or dependent resource is in progress. To retrieve status of the operation use uri: https://management.azure.com/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/providers/Microsoft.Network/locations/uksouth/operations/ef9f087b-0448-44a2-ab05-9579837bf9de?api-version=2021-08-01.\\\",\\r\\n \\\"details\\\": []\\r\\n }\\r\\n}\"\r\n }\r\n ]\r\n }\r\n ]\r\n }\r\n}"}]}}

我还注意到行为不一致。有时不创建子网,有时只创建一个子网。我有时也可以通过多次部署来成功完成部署!

最佳答案

这里的问题是子网模块是并行部署的。他们都尝试同时更新 vnet,从而导致您看到的冲突错误。

在这种情况下,您可以使用 module decorator :

By default, resources are deployed in parallel. When you add the batchSize decorator, you deploy instances serially.

所以这应该有效:

@batchSize(1)
module subnetsym 'modules/subnet.bicep' = [for subnet in vnet.subnets: {
...

您还应该在 vnet 资源内部署子网。如果您重新运行模板,它将在重新创建子网之前将其删除。有几个相关问题:

关于Azure Bicep - 部署失败(冲突)对此资源或依赖资源的另一项操作正在进行中 (AnotherOperationInProgress),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72621266/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com