Vnet创建任务如果运行一次,则跳过该任务 [英] Vnet creation task skip the task if it is run once

查看:53
本文介绍了Vnet创建任务如果运行一次,则跳过该任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为AKS构建ci/cd管道.第一个任务集是"Azure资源组部署",用于为AKS创建vnet/subnet.
由于vnet和子网已经存在,因此下一次将跳过此任务.第二次以后出现以下错误-

I am working to build a ci/cd pipeline for AKS. the first task set is "Azure resource group deployment" which is used for creating vnet /subnet for the AKS .
The intention is to skip the task next time onwards since the vnet and subnet are already in place. Second time onwards getting the following error -

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. 

看起来任务正在尝试删除子网,而不是跳过子网.分辨率是多少?

Looks like the task is trying to delete the subnet instead of skipping it. What is the resolution?

它正在使用以下手臂模板:azuredeploy.json

It is using following arm templates : 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

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": "######"
    }
  }
}

推荐答案

这是怎么回事-您的模板以这种方式编码:

What is happening right here - your template is coded in such a fashion:

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

,由于您创作模板的方式,这里正在发生的事情试图将vnet强制为0个子网.您有2个选择:

and what is happening here it is trying to coerce the vnet to have 0 subnets, due to how you authored your template. you have 2 options:

  1. 如果内部版本号大于1(或仅在构建时手动指定是否跳过它),则对vnet资源定义施加条件并向其传递参数.
  2. 修改模板,使其看起来像这样:

vnet resource
  subnets property populated with subnets
bla-bla-bla

本质上,这与Azure Devops无关.

essentially, this has nothing to do with Azure Devops.

这篇关于Vnet创建任务如果运行一次,则跳过该任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆