从 azure devops 二头肌部署访问输出值

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

我有一个 Azure Devops Release 管道,其中包含 ARM 模板部署步骤。 它实际上部署了一个二头肌文件 二头肌有以下输出 -

output deployedItems array = [for (location, i) in locations: {
  item: module[i].outputs.app
}]

基本上是早期模块中的对象数组 在数组中,因为前面的模块在 For 循环中被调用,对于传递到二头肌的每个位置一次调用

这部署得很好

在 ARM 模板部署步骤中,我将“部署输出”设置为 bicepOutput

到目前为止一切都很好

现在,在后面的步骤中,我想从此输出访问一个属性,这就是轮子从总线上脱落的地方。

输出看起来与此类似(为简洁起见进行了编辑)-`

"deployedItems": {
        "type": "Array",
        "value": [
            {
                "item": {
                    "apiVersion": "2023-01-01",
                    "location": "Australia East",
                    "properties": {
                        "name": "testapp2".....
                     }
                 }
             }
         ]

我正在尝试以下操作来访问上面代码片段中的项目名称

$(bicepOutput.deployedItems[0].item.properties.name)

但这没有任何作用。 我如何从这个输出中获取这个属性的值?

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

任务的输出为

string
格式,您需要在 Powershell/Azure Powershell 任务中使用
ConvertFrom-Json
Powershell cmdlet 解析为 JSON 对象,然后该对象可以在同一任务或后续任务中使用。

来自任务:

来自任务指南

这里有一个类似的ticket,带有示例powershell供您参考。

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