MicrosoftDocs / azure-docs

Open source documentation of Microsoft Azure
https://docs.microsoft.com/azure
Creative Commons Attribution 4.0 International
10.01k stars 21k forks source link

Restrictions Not Displayed in 'Default Value' Section #122142

Open influential-eliot opened 2 weeks ago

influential-eliot commented 2 weeks ago

Restrictions For 'Default Value' Are Non-Existent Or Unclear

I would suggest that the restrictions on the Default Value are a bit too obfuscated and/or unlisted here.

A validation problem (at least when using VS Code - latest) occurs when attempting to use a Variable in the Default Value.

If this is a restricted ability, then it should be shown as such at the top of the Default Value section, perhaps in an ℹ️ panel, or something.

Clarification: I am not raising a validation incident here, merely raising that if such behaviour is restricted, then it should be displayed in the document.


Example

For example, let's say that I have the following parameters and variables:

{
    "parameters": {
        "environment": {
          "defaultValue": "[variables('env')]",
          "type": "String"
        }
    },
    "variables": {
        "env": "Some_text"
    }
}

This will produce a validation error akin to:

Template validation failed: The template resource 'environment' at ... is not valid: The template function 'variables' is not expected at this location.

This also occurs when wrapping a string() function around the variables() call in the defaultValue.

Further Details

There is a line which states the following:

You can't use the reference function or any of the list functions in the parameters section.

However that doesn't state that using a variable in a defaultValue will fail template validation.


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

PesalaPavan commented 2 weeks ago

@influential-eliot Thanks for your feedback! We will investigate and update as appropriate.

AnuragSingh-MSFT commented 1 week ago

@influential-eliot, thank you for the feedback.

@mumian, could you please review this feedback and share your thoughts. Thank you