【发布时间】:2019-12-26 05:38:36
【问题描述】:
我正在为 AKS 构建 ci/cd 管道。第一个任务集是“Azure 资源组部署”,用于为 AKS 创建 vnet /subnet。
由于 vnet 和子网已经就位,因此打算下次跳过该任务。第二次开始出现以下错误-
BadRequest: { "error": { "code": "InUseSubnetCannotBeDeleted", "message": "Subnet AKSSubnet is in use by /subscriptions/***************************************/resourceGroups/MC_**************-CLUSTER_eastus/providers/Microsoft.Network/networkInterfaces/aks-agentpool-
########-nic-0/ipConfigurations/ipconfig1 and cannot be deleted. In order to delete the subnet, delete all the resources within the subnet. See aka.ms/deletesubnet.", "details": [] } }
Error: Task failed while creating or updating the template deployment.
看起来该任务正在尝试删除子网而不是跳过它。分辨率是多少?
它使用以下 arm 模板:azuredeploy.json
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vnetName": {
"type": "string",
"defaultValue": "GEN-VNET-NAME",
"metadata": {
"description": "Name of the virtual Network"
}
},
"vnetAddressPrefix": {
"type": "string",
"defaultValue": "10.10.0.0/16",
"metadata": {
"description": "Address prefix"
}
},
"subnetPrefix": {
"type": "string",
"defaultValue": "10.10.0.0/24",
"metadata": {
"description": "Subnet Prefix"
}
},
"subnetName": {
"type": "string",
"defaultValue": "Subnet",
"metadata": {
"description": "GEN-SUBNET-NAME"
}
}
},
"variables": {},
"resources": [
{
"apiVersion": "2018-06-01",
"type": "Microsoft.Network/virtualNetworks",
"name": "[parameters('vnetName')]",
"location": "[resourceGroup().location]",
"properties": {
"addressSpace": {
"addressPrefixes": [
"[parameters('vnetAddressPrefix')]"
]
}
},
"resources": [
{
"apiVersion": "2018-06-01",
"type": "subnets",
"location": "[resourceGroup().location]",
"name": "[parameters('subnetName')]",
"dependsOn": [
"[parameters('vnetName')]"
],
"properties": {
"addressPrefix": "[parameters('subnetPrefix')]"
}
}
]
}
],
"outputs": {
"vnetName": {
"type": "string",
"value": "[parameters('vnetName')]"
},
"subnetName": {
"type": "string",
"value": "[parameters('subnetName')]"
}
}
}
azuredeploy.parameters.json
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vnetName": {
"value": "###########"
},
"vnetAddressPrefix": {
"value": "10.10.0.0/16"
},
"subnetPrefix": {
"value": "10.10.0.0/24"
},
"subnetName": {
"value": "######"
}
}
}
【问题讨论】:
-
你能澄清一下你运行任务的条件是什么吗?即总是运行它?或者你有条件吗?您正在使用任务的哪个“动作”?请注意,您可能正在使用 Azure 模板的“增量模式”,它们将确保跳过不需要再次运行的内容(例如,如果创建了资源并且它处于您的所需状态,则不受任务执行的影响)。
-
这是误导,部署模式无关紧要,它并没有真正跳过资源,如果没有什么要更新的,它只是不更新它们,本质上它调用了api,但是因为有无需进行任何更改 - 什么都没有发生
-
@luca cappa 使用了增量模式。如错误所示,它仍然尝试删除现有子网,然后可能会尝试构建子网。
标签: azure azure-devops azure-pipelines