gpt4 book ai didi

azure - 在 Azure Pipelines 中用 FileTransform@1 替换变量时,可以采取哪些步骤来修复 InvalidRequestContent 错误?

转载 作者:行者123 更新时间:2023-12-02 23:34:17 24 4
gpt4 key购买 nike

FileTransform@1 变量替换失败

我正在尝试将 main.parameters.json 文件中的值替换为变量组中的变量值。

文件转换给出一个绿色的勾,并表示该值已被替换,但是假设给出了错误。

这是错误:

ERROR: {"error":{"code":"InvalidRequestContent","message":"The request content was invalid and could not be deserialized: 'Error converting value "test" to type 'Azure.Deployments.Core.Definitions.DeploymentParameterDefinition'. Path 'properties.parameters.tier', line 1, position 81.'."}}##[error]Script failed with exit code: 1

这是我的 yaml 代码的一部分:

`trigger:
batch: true
branches:
include:
- master
paths:
include:
- bicep

pool:
vmImage: windows-latest

variables:
- group: myGroup
- name: parameters.tier
value: "$(tier)"

stages:

- stage: Preview
jobs:
- job: PreviewAzureChanges
displayName: Preview Azure changes
steps:
- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
echo "Print tier value"
echo "Value: $(tier)"

- task: FileTransform@1
displayName: 'File transformation: main.parameters.json'
inputs:
folderPath: 'bicep\'
targetFiles: 'main.parameters.json'
fileType: json

- task: AzureCLI@2
name: RunWhatIf
displayName: Run what-if
inputs:
azureSubscription: $(environment)
scriptType: bash
scriptLocation: inlineScript
inlineScript: |
az deployment group what-if \
--resource-group $(rg) \
--template-file 'bicep\main.bicep' \
--parameters 'bicep\main.parameters.json'`

这是我的 main.parameters.json:

{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"franchisee": {
"value": "myFranchisee"
},
"tier": {
"value": "myTier"
},
"location": {
"value": "myLocation"
},
"rg": {
"value": "myRg"
}
}
}

最佳答案

解决办法就是改变

variables:
- group: myGroup
- name: parameters.tier
value: "$(tier)"

variables:
- group: myGroup
- name: parameters.tier.value
value: "$(tier)"

关于azure - 在 Azure Pipelines 中用 FileTransform@1 替换变量时,可以采取哪些步骤来修复 InvalidRequestContent 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76305907/

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