使用 Azure 发布管道在 Dev、Stage 和 Production 插槽上部署期间替换/更新 json 文件的值 [英] Replace/Update json file's values during deployment on Dev, Stage and Production slots using Azure Release pipelines

本文介绍了使用 Azure 发布管道在 Dev、Stage 和 Production 插槽上部署期间替换/更新 json 文件的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Azure 的新手,我有一项任务要在部署时更新 json 文件的值.我在 Azure 发布管道 Dev、Stage 和 Prod 中有 3 个部署槽.

我有以下 Json 文件需要更新.

表格":[{"name": "客户合同",列": [{"name": "年份",数据类型":int64","sourceColumn": "年份","summarizeBy": "无"},{"name": "",数据类型":int64","sourceColumn": "客户编号","summarizeBy": "无",isHidden":<trueifdev>}],分区":[{"name": "分区",数据视图":完整"}]},}

在上面的 json 文件中,我需要更新以下键的值.

  • 是隐藏的"
  • 姓名"

以上两个键的值因插槽(Dev、Stage 和 Prod)而异.

请帮助我如何在部署时根据插槽更改/更新上述键的值?

以下链接在我的情况下不起作用,因为我的 json 文件属于共享点数据模型.

并根据阶段在变量上定义键的值:

作为阶段Stage的测试结果:

<代码> {"name": "TDev456",数据类型":int64","sourceColumn": "客户编号","summarizeBy": "无",isHidden":假}

键的值 name &isHidden 已更新为 TDev456 &错误.

希望这会有所帮助.

I am quite new in Azure and i have a task to update a json file's values at deployment time. I have 3 deployment slots in Azure release pipeline Dev, Stage and Prod.

I have following Json file which need to update.

"tables": [{
    "name": "CustomerContract",
    "columns": [{
               "name": "Year",
               "dataType": "int64",
               "sourceColumn": "Year",
               "summarizeBy": "none"
           },
           {
               "name": "<devname>",
               "dataType": "int64",
               "sourceColumn": "CustomerNumber",
               "summarizeBy": "none",
               "isHidden": <trueifdev>
           }
    ],
    "partitions": [{
        "name": "Partition",
        "dataView": "full"
    }]
  },
}

In above json file i need to update following key's values.

  • "isHidden"
  • "name"

above two key's values are different based on slots (Dev, Stage & Prod).

Please help me out how can i change/update the values of above keys at deployment time based on slots?

Following link didn't worked in my case because my json files belongs to sharepoint data models.

Azure Dev ops replace tokens per environment in release pipeline

解决方案

Please help me out how can i change/update the values of above keys at deployment time based on slots?

If the Json file is not generated during building. We still could use the task Replace Tokens to update the key's values.

As test, change the definition of the key's values:

"tables": [{
    "name": "CustomerContract",
    "columns": [{
               "name": "Year",
               "dataType": "int64",
               "sourceColumn": "Year",
               "summarizeBy": "none"
           },
           {
               "name": "#{DevName}#",
               "dataType": "int64",
               "sourceColumn": "CustomerNumber",
               "summarizeBy": "none",
               "isHidden": #{trueifdev}#
           }
    ],
    "partitions": [{
        "name": "Partition",
        "dataView": "full"
    }]
  },
}

The format of variable in .json file is #{DevName}# & #{trueifdev}#.

Copy this file to the artifact and use Replace Tokens task to update the key's values:

And define the key's values on the Variables based on the stages:

As test result for stage Stage:

       {
           "name": "TDev456",
           "dataType": "int64",
           "sourceColumn": "CustomerNumber",
           "summarizeBy": "none",
           "isHidden": False
       }

The key's values name & isHidden have been updated to TDev456 & False.

Hope this helps.

这篇关于使用 Azure 发布管道在 Dev、Stage 和 Production 插槽上部署期间替换/更新 json 文件的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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