0
votes

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?

This works fine when deploying via powershell locally. But using that task in Azure Devops, it doesn't translate the utcNow function?

The tag comes out as the string representation. i.e.

enter image description here

I'm building the tags as a variable. i.e.

// 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'))]",
1
How are you setting the utcShort parameter?Jason P
Sorry, i guess i missed that important part. I've updated the question, but it's by the defaultValue. i.e ``` "utcShort": { "type": "string", "defaultValue": "[utcNow('d')]" },randy
What does the configuration or your task look like? (screenshot?)bmoore-msft

1 Answers

0
votes

The issue was i was using the Release feature of the Devops pipeline, not the 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. 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. Otherwise Devops was enclosing it with quotes and treating it as a string.