Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template validation fails when defaultValue uses a function and allowedValues is specified #1683

Open
jordanmills opened this issue Feb 20, 2024 · 0 comments

Comments

@jordanmills
Copy link

In cases where a template is validated before runtime and contains ARM functions cannot be evaluated (i.e. in an editor as opposed to at deployment), I believe the expectation would be that validation for allowedValues or other constraints would be ignored.

Example:

"parameters": {
    "environment": {
        "defaultValue": "[substring(resourceGroup().name, sub(length(resourceGroup().name), 3), 3)]",
        "allowedValues": [
            "prd",
            "stg",
            "qat",
            "uat",
            "tst",
            "dev"
        ],
        "type": "string"
    }
}

Say I want the default value of this parameter to be the last three letters of the resource group to which it is deployed. This generates a validation failure. It also generates a validation failure if the value for defaultValue is added to the array of allowedValues. Oddly with a reference to Front Door (but I think that is a known issue with template validation messages). Admittedly this is a silly example that does not seem to work as hoped any way, but it illustrates the issue.

At any rate, I would expect that neither would fail in the editor.

I think it would also be reasonable to skip validation for all parameters with defaultValue values that contain any functions (not just functions that cannot be evaluated before deployment time). Seems like lots of work for an edge case with low return any way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant