【问题标题】:Azure Devops Release Pipeline - ARM - utcNowAzure Devops 发布管道 - ARM - utcNow
【发布时间】:2021-06-24 06:42:16
【问题描述】:

有谁知道在 Azure Devops Release 管道中通过 - task: AzureResourceManagerTemplateDeployment@3 进行部署时,像文档 (https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/template-functions-date?tabs=json#examples-1) 所说的那样,让 utcNow 作为默认参数工作吗?

在本地通过 powershell 部署时,这可以正常工作。但是在 Azure Devops 中使用该任务,它不会翻译 utcNow 函数?

标签以字符串表示形式出现。即

我将标签构建为变量。即

//参数文件

   "resourceTags": {
        "value": {
            "Environment": "Dev",
            "ApplicationName": "MyApp"
        }
    },

// 参数

    "utcShort": {
        "type": "string",
        "defaultValue": "[utcNow('d')]"
    },

    "resourceTags": {
        "type": "object"
    },

// 变量

    "lastDeployed": {
        "LastDeployed": "[parameters('utcShort')]"
    },
    "resourceTags": "[union(parameters('resourceTags'), variables('lastDeployed'))]",

【问题讨论】:

  • 你是如何设置utcShort参数的?
  • 对不起,我想我错过了那个重要的部分。我已经更新了问题,但它是默认值。即``` "utcShort": { "type": "string", "defaultValue": "[utcNow('d')]" },
  • 配置或您的任务是什么样的? (截图?)

标签: azure azure-devops azure-resource-manager


【解决方案1】:

问题是我使用的是 Devops 管道的发布功能,而不是 yaml。当我在 UI 中选择参数 json 文件时,它会引入所有参数,即使是参数文件中未明确指定的参数。我不想显式设置这个参数,所以它会使用默认值。喜欢,

  "utcShort": {
        "type": "string",
        "defaultValue": "[utcNow('d')]"
    },

所以,我不得不从参数列表中删除这个 utcShort 参数,所以它会使用默认值。否则 Devops 会用引号将其括起来并将其视为字符串。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-02-18
    • 2019-04-29
    • 2022-12-05
    • 2021-12-11
    • 2021-12-31
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多