参数文件中的部署模板验证失败的模板参数'scriptUrldsc'无效,它们不存在于原始文件中

问题描述 投票:0回答:1

我收到有关该主题的错误,我正在努力解决。我正在使用带有多个嵌套ARM模板的ARM模板,正在使用Azure DevOps进行部署。

模板下方。

第一个模板是调用嵌套模板的模板:

{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
  "existingDataFactoryName": {
    "type": "string",
    "metadata": {
      "description": "Existing Data Factory name"
    }
  },
  "existingDataFactoryResourceGroup": {
    "type": "string",
    "metadata": {
      "description": "Existing Data Factory resource group"
    }
  },
  "existingDataFactoryVersion": {
    "type": "string",
    "metadata": {
      "description": "Select the existing Data Factory version"
    },
    "allowedValues": [
      "V1",
      "V2"
    ]
  },
  "virtualMachineName": {
    "type": "string",
    "metadata": {
      "description": "Virtual Machine Name where the runtime will run. Please don't provide the last numbers of the VM E.g: EUWE01PROJNIR "
    }
  },
  "IntegrationRuntimeName": {
    "type": "string",
    "metadata": {
      "description": "IR name must be unique in subscription"
    }
  },
  "NodeCount": {
    "type": "int",
    "maxValue": 4,
    "minValue": 1,
    "metadata": {
      "description": "the node count is between 1 and 4."
    }
  },
  "vmSize": {
    "type": "string",
    "defaultValue": "Standard_A4_v2"
  },
  "adminUserName": {
    "type": "string",
    "metadata": {
      "description": "User name for the virtual machine"
    }
  },
  "adminPassword": {
    "type": "securestring",
    "metadata": {
      "description": "Password for the virtual machine"
    }
  },
  "existingVirtualNetworkName": {
    "type": "string",
    "metadata": {
      "description": "Existing vnet name"
    }
  },
  "existingVnetLocation": {
    "type": "string",
    "metadata": {
      "description": "Virtual machine will be create in the same datacenter with VNET"
    }
  },
    "existingVnetResourceGroupName": {
    "type": "string",
    "metadata": {
      "description": "Name of the existing VNET resource group"
    }
  },
  "existingSubnetInYourVnet": {
    "type": "string",
    "metadata": {
      "description": "Name of the subnet in the virtual network you want to use"
    }
  },
  "_artifactsLocation": {
    "type": "string",
    "metadata": {
      "description": "The base URI where artifacts required by this template are located."
    },
    "defaultValue": "[deployment().properties.templateLink.uri]"
  },
  "_artifactsLocationSasToken": {
    "type": "securestring",
    "metadata": {
      "description": "The sasToken required to access _artifactsLocation.  When the template is deployed using the accompanying scripts, a sasToken will be automatically generated."
    },
    "defaultValue": ""
  },
  "diagnosticsStorageAccountName": {
    "type": "string",
    "metadata": {
      "description": "Diagnostic storage account name"
    },
    "defaultValue": ""
  },
    "storageAccountNameRG": {
    "type": "string",
    "metadata": {
      "description": "Diagnostic Resource Group of the Diagnostic storage account"
    },
    "defaultValue": ""
  },
    "availabilitySetName": {
    "type": "string",
    "metadata": {
      "description": "Availability Set Name"
    },
    "defaultValue": ""
  }

},
"variables": {
  "delimiters": [
    "-",
    "_"
  ],      

  "prefix": "[split(parameters('IntegrationRuntimeName'), variables('delimiters'))[0]]",
  "vmTemplateLink": "[uri(parameters('_artifactsLocation'), concat('nested/VMtemplate.json', parameters('_artifactsLocationSasToken')))]",
  "irInstallTemplateLink": "[uri(parameters('_artifactsLocation'), concat('nested/IRInstall.json', parameters('_artifactsLocationSasToken')))]",
  "IRtemplateLink": "[uri(parameters('_artifactsLocation'), concat('nested/IRtemplate.json', parameters('_artifactsLocationSasToken')))]",
  "subnetId": "[resourceId(parameters('existingVnetResourceGroupName'), 'Microsoft.Network/virtualNetworks/subnets', parameters('existingVirtualNetworkName'), parameters('existingSubnetInYourVnet'))]",
  "scriptURL": "[uri(parameters('_artifactsLocation'), concat('gatewayInstall.ps1', parameters('_artifactsLocationSasToken')))]",
  "scriptURLdsc": "[uri(parameters('_artifactsLocation'), concat('DscMetaConfigs.ps1', parameters('_artifactsLocationSasToken')))]"
},
"resources": [
  {
    "type": "Microsoft.Resources/deployments",
    "apiVersion": "2019-09-01",
    "name": "nestedTemplate",
    "resourceGroup": "[parameters('existingDataFactoryResourceGroup')]",
    "properties": {
      "mode": "Incremental",
      "templateLink": {
        "uri": "[variables('IRtemplateLink')]",
        "contentVersion": "1.0.0.0"
      },
      "parameters": {
        "existingDataFactoryName": {
          "value": "[parameters('existingDataFactoryName')]"
        },
        "existingDataFactoryVersion": {
          "value": "[parameters('existingDataFactoryVersion')]"
        },
        "IntegrationRuntimeName": {
          "value": "[parameters('IntegrationRuntimeName')]"
        }
      }
    }
  },
  {
    "type": "Microsoft.Resources/deployments",
    "apiVersion": "2019-09-01",
    "name": "[concat('VMtemplate-', copyIndex())]",
    "dependsOn": [
      "[resourceId(parameters('existingDataFactoryResourceGroup'), 'Microsoft.Resources/deployments', 'nestedTemplate')]"
    ],
    "copy": {
      "name": "vmcopy",
      "count": "[parameters('NodeCount')]"
    },
    "properties": {
      "mode": "Incremental",
      "templateLink": {
        "uri": "[variables('vmTemplateLink')]",
        "contentVersion": "1.0.0.0"
      },
      "parameters": {
        "virtualMachineName": {
          "value": "[take(concat(parameters('virtualMachineName'),'0',copyIndex(1)), 15)]"
        },
        "vmSize": {
          "value": "[parameters('vmSize')]"
        },
        "adminUserName": {
          "value": "[parameters('adminUserName')]"
        },
        "adminPassword": {
          "value": "[parameters('adminPassword')]"
        },
        "existingVnetLocation": {
          "value": "[parameters('existingVnetLocation')]"
        },
        "subnetId": {
          "value": "[variables('subnetId')]"
        },
        "diagnosticsStorageAccountName": {
          "value": "[parameters('diagnosticsStorageAccountName')]"
        },
        "availabilitySetName": {
        "value":  "[parameters('availabilitySetName')]"
        },
        "storageAccountNameRG": {
          "value":  "[parameters('storageAccountNameRG')]"
        }
      }
    }
  },
  {
    "apiVersion": "2019-09-01",
    "type": "Microsoft.Resources/deployments",
    "name": "[concat('IRInstalltemplate-', copyIndex())]",
    "dependsOn": [
      "vmcopy"
    ],
    "copy": {
      "name": "irinstallcopy",
      "count": "[parameters('NodeCount')]",
      "mode": "serial"
    },
    "properties": {
      "mode": "Incremental",
      "templateLink": {
        "uri": "[variables('irInstallTemplateLink')]",
        "contentVersion": "1.0.0.0"
      },
      "parameters": {
        "existingDataFactoryVersion": {
          "value": "[parameters('existingDataFactoryVersion')]"
        },
        "datafactoryId": {
          "value": "[reference(resourceId(parameters('existingDataFactoryResourceGroup'), 'Microsoft.Resources/deployments', 'nestedTemplate')).outputs.irId.value]"
        },
        "virtualMachineName": {
          "value": "[take(concat(parameters('virtualMachineName'),'0',copyIndex(1)), 15)]"
        },
        "existingVnetLocation": {
          "value": "[parameters('existingVnetLocation')]"
        },
        "scriptUrl": {
          "value": "[variables('scriptURL')]"
        },
        "scriptUrldsc": {
          "value": "[variables('scriptURLdsc')]"
        }
      }
    }
  }
]

}

这是在嵌套模板内部使用“ scriptUrldsc”参数的位置。

{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
  "existingDataFactoryVersion": {
    "type": "string"
  },
  "datafactoryId": {
    "type": "string"
  },
  "virtualMachineName": {
    "type": "string"
  },
  "existingVnetLocation": {
    "type": "string"
  },
  "scriptUrl": {
    "type": "string"
  },
  "scriptUrldsc": {
    "type": "string"
  }
},
"variables": {},
"resources": [
  {
    "type": "Microsoft.Compute/virtualMachines/extensions",
    "name": "[concat(parameters('virtualMachineName'), '/' ,parameters('virtualMachineName'), '-installGW')]",
    "apiVersion": "2019-07-01",
    "location": "[parameters('existingVnetLocation')]",
    "tags": {
      "virtualMachineName": "[parameters('virtualMachineName')]"
    },
    "properties": {
      "publisher": "Microsoft.Compute",
      "type": "CustomScriptExtension",
      "typeHandlerVersion": "1.7",
      "autoUpgradeMinorVersion": true,
      "settings": {
        "fileUris": [
          "[parameters('scriptURL')]",
          "[parameters('scripturldsc')]"
        ]
      },
      "protectedSettings": {
        "commandToExecute": "[concat('powershell.exe -ExecutionPolicy Unrestricted -File gatewayInstall.ps1', if(equals(parameters('existingDataFactoryVersion'), 'V2'), listAuthKeys(parameters('datafactoryId'), '2017-09-01-preview').authKey1, listAuthKeys(parameters('datafactoryId'), '2015-10-01').key1))]"
      }
    }
  }
]

}

azure azure-devops azure-resource-manager
1个回答
0
投票

错误消息表明存储Blob中的ARM模板缺少参数scriptUrldsc。假设最近添加了参数scriptUrldsc,则也许模板已在本地更新以添加参数,但是不知何故存储Blob中的版本未使用新参数进行更新。

© www.soinside.com 2019 - 2024. All rights reserved.