我们希望采取一项临时措施,即在QA环境中保持ADF触发器停止,但在生产环境中保持其启动。
我试图在我们的Azure DevOps管道中覆盖此参数,我们已经为QA和生产定义了变量。
我遵循了与覆盖其他参数相同的语法,但当Azure DevOps进行部署时(成功构建)会出现以下错误:
[error]部署模板验证失败:“parameters文件中的模板参数'TriggerName_properties_runtimeState'无效;它们不存在于原始模板中,因此无法在部署时提供。此模板唯一支持的参数是....有关用法详细信息,请参阅https://aka.ms/arm-pass-parameter-values。”
这就是我的模板deploy-adf.yml
中的内容:
parameters:
...
- name: triggerNameTriggerRunState
type: string
jobs:
- deployment: Deploy_${{ parameters.environment }}
strategy:
runOnce:
deploy:
steps:
...
- task: AzureResourceManagerTemplateDeployment@3
displayName: 'Deploying to ${{ parameters.environment }}'
inputs:
deploymentScope: 'Resource Group'
azureResourceManagerConnection: ${{ parameters.serviceConnection }}
subscriptionId: '$(subscriptionId)'
action: 'Create Or Update Resource Group'
resourceGroupName: '${{ parameters.adfResourceGroupName }}'
location: '$(location)'
templateLocation: 'Linked artifact'
csmFile: '$(Pipeline.Workspace)/build/adf-artifact-${{ parameters.version}}/ARMTemplateForFactory.json'
csmParametersFile: '$(Pipeline.Workspace)/build/adf-artifact-${{ parameters.version}}/ARMTemplateParametersForFactory.json'
overrideParameters: >-
...
-TriggerName_properties_runtimeState "${{ parameters.triggerNameTriggerRunState }}"
deploymentMode: 'Incremental'
字符串
如上所述,它成功构建,但是当我查看ARMTemplateForFactory.json
生成的Artifacts文件时:
{
"name": "[concat(parameters('factoryName'), '/TriggerName')]",
"type": "Microsoft.DataFactory/factories/triggers",
"apiVersion": "2018-06-01",
"properties": {
"annotations": [],
"runtimeState": "Started",
"pipelines": [
{
"pipelineReference": {
"referenceName": "Pipeline name",
"type": "PipelineReference"
},
"parameters": {
"sourceFolder": "[parameters('TriggerName_properties_Pipeline name_parameters_sourceFolder')]",
"sourceFile": "[parameters('TriggerName_properties_Pipeline name_parameters_sourceFile')]"
}
}
],
"type": "BlobEventsTrigger",
"typeProperties": {
"blobPathBeginsWith": "/container/blobs/sub_directory",
"ignoreEmptyBlobs": true,
"scope": "[parameters('TriggerName_properties_typeProperties_scope')]",
"events": [
"Microsoft.Storage.BlobCreated"
]
}
},
"dependsOn": [
"[concat(variables('factoryId'), '/pipelines/Pipeline name')]"
]
},
型
我注意到runtimeState
没有被参数化。我不太确定这个文件是如何生成的。这是否意味着不可能覆盖runtimeState
?或者在构建文件中缺少一些我需要做的事情。
请注意,这是我们的Azure Devops构建文件的摘录:
...
variables:
- template: ./vars/vars.qa.yml
stages:
- stage: Build_And_Publish_ADF_Artifacts
displayName: "Build and publish ADF"
jobs:
- job: Build_Adf_Arm_Template
displayName: "Build ADF ARM template"
steps:
- checkout: self
persistCredentials: "true"
fetchDepth: 0
- task: gitversion/setup@0
displayName: GitVersion setup
inputs:
versionSpec: "5.x"
- task: gitversion/execute@0
displayName: Determine next version
name: Version
- script: |
echo ##vso[build.updatebuildnumber]$(SEMVER)
echo ##vso[task.setvariable variable=imageTag;isOutput=true]$(SEMVER)
displayName: Update Build Number
name: buildNumber
- task: NodeTool@0
inputs:
versionSpec: "16.x"
displayName: "Install Node.js"
- task: Npm@1
inputs:
command: "install"
workingDir: "$(Build.SourcesDirectory)/data_factory"
verbose: true
displayName: "Install NPM Package"
- task: Npm@1
displayName: "Validate ADF Code"
inputs:
command: "custom"
workingDir: "$(Build.SourcesDirectory)/data_factory"
customCommand: "run build validate $(Build.SourcesDirectory)/data_factory $(adfResourceId)"
- task: Npm@1
displayName: "Validate and Generate ARM template"
inputs:
command: "custom"
workingDir: "$(Build.SourcesDirectory)/data_factory"
customCommand: 'run build export $(Build.SourcesDirectory)/data_factory $(adfResourceId) "ArmTemplate"'
- task: PublishPipelineArtifact@1
displayName: Download Build Artifacts - ADF ARM templates
inputs:
targetPath: "$(Build.SourcesDirectory)/data_factory/ArmTemplate" #replace with the package.json folder.
artifact: "adf-artifact-$(Build.BuildNumber)"
publishLocation: "pipeline"
...
型
1条答案
按热度按时间lokaqttq1#
当ARMTemplateParametersForFactory.json(ARM模板参数文件)和ARMTemplateParametersForFactory.json ARM模板文件中指定的参数不匹配时,会发生此问题。
参数文件中的TriggerName_properties_runtimeState无效。您需要在ARM模板的parameters部分中检查是否指定或使用了此参数。
如果参数是在参数文件中定义的,而不是在主模板中使用。它将显示此错误。
我可以复制类似的问题。
的数据
要解决此问题,您可以在ARMTemplateParametersForFactory.json文件中定义参数。
举例来说:
参数文件:
字符串
主模板:
型
如果您没有在模板中使用此参数,请将其从参数文件ARMTemplateParametersForFactory.json中删除,它应该可以修复此问题。
要获取更多关于ARM模板参数的信息,您可以参考此文档:Tutorial: Use parameter files to deploy your ARM template