gpt4 book ai didi

azure - Vnet 创建任务如果运行一次则跳过该任务

转载 作者:行者123 更新时间:2023-12-03 05:40:07 25 4
gpt4 key购买 nike

我正在努力为 AKS 构建 ci/cd 管道。第一个任务集是“Azure 资源组部署”,用于为 AKS 创建 vnet/子网。
目的是下次跳过该任务,因为 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": "######"
}
}
}

最佳答案

这里发生了什么 - 您的模板是以这样的方式编码的:

vnet resources
empty subnets property
subnet resource(s)
bla-bla-bla

这里发生的事情是,由于您编写模板的方式,它试图强制 vnet 有 0 个子网。您有 2 个选择:

  1. 在 vnet 资源定义上添加一个条件,如果构建号大于 1,则向其传递一个参数(或者只是在构建时手动指定是否跳过它)。
  2. 修改您的模板,如下所示:
vnet resource
subnets property populated with subnets
bla-bla-bla

本质上,这与 Azure DevOps 无关。

关于azure - Vnet 创建任务如果运行一次则跳过该任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59484247/

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