简体   繁体   English

Azure Devops 发布管道 - ARM - utcNow

[英]Azure Devops Release Pipeline - ARM - utcNow

Does anyone know who to get utcNow to work as a default parameter like the documentation ( https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/template-functions-date?tabs=json#examples-1 ) says when deploying via the - task: AzureResourceManagerTemplateDeployment@3 in an Azure Devops Release pipeline?有谁知道让 utcNow 像文档一样作为默认参数工作( https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/template-functions-date?tabs=json #examples-1 )在通过- task: AzureResourceManagerTemplateDeployment@3

This works fine when deploying via powershell locally.在本地通过 powershell 部署时,这可以正常工作。 But using that task in Azure Devops, it doesn't translate the utcNow function?但是在 Azure Devops 中使用该任务,它不会翻译 utcNow function?

The tag comes out as the string representation.该标签以字符串表示形式出现。 ie IE

在此处输入图像描述

I'm building the tags as a variable.我将标签构建为变量。 ie IE

// parameters file // 参数文件

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

// parameters // 参数

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

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

// variables // 变量

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

The issue was i was using the Release feature of the Devops pipeline, not the yaml.问题是我使用的是 Devops 管道的发布功能,而不是 yaml。 When i selected the parameter json file in the UI, it brought in all the parameters, even the ones not explicitly specified in the parameters file.当我在 UI 中选择参数 json 文件时,它会引入所有参数,即使是参数文件中未明确指定的参数。 I don't want to explicitly set this parameter, so it will use the default.我不想显式设置这个参数,所以它会使用默认值。 like,喜欢,

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

So, i had to delete this utcShort parm out of the list of parameters, so it would use the default.所以,我不得不从参数列表中删除这个 utcShort 参数,所以它会使用默认值。 Otherwise Devops was enclosing it with quotes and treating it as a string.否则 Devops 会用引号将其括起来并将其视为字符串。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM