microsoft / vscode-azurearmtools

Azure Resource Manager Tools for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=msazurermtools.azurerm-vscode-tools
MIT License
135 stars 81 forks source link

indexOf expected parameters wrong #1515

Open ghost opened 2 years ago

ghost commented 2 years ago

Hey,

we tested ARM/AzurePolicies with the indexOf/ lastIndexOf functions. Both support arrays according to docs. But the vscode extension complains that only strings are supported:

"[
    indexOf(
        parameters('testingArray'),
        'test02')
]"
Template validation failed: The template variable 'test' is not valid: The template language function 'indexOf' expects its parameters to be of type string and string. The provided value is of type 'Array' and 'String'. Please see https://aka.ms/arm-template-expressions#indexOf for usage details.. Please see https://aka.ms/arm-template-expressions for usage details.arm-template (validation)

We used the following template as a test:

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "resources": [],
    "parameters": {
        "testingArray": {
            "type": "array",
            "metadata": {
                "description": "description"
            },
            "defaultValue": [
                "test00",
                "test01",
                "test02",
                "test03"
            ]
        }
    },
    "variables": {
        "test": "[indexOf(parameters('testingArray'), 'test02')]"
    },
    "outputs": {
        "output1": {
            "type": "int",
            "value": "[variables('test')]"
        }
    }
}

The template is working as expected when deployed to azure.

The Azure Policy Extension has the same Bug so i expect the error somewhere deeper, but i couldn't find a Repo for the language server. So please let me know if this can be fixed for both extensions in the language server or I need to open another issue for the other extension.

Best regards Thimo

StephenWeatherford commented 2 years ago

@QBY-ThimoLimpert You should also open a bug against the other extension, thanks.

StephenWeatherford commented 2 years ago

Blocked by https://github.com/microsoft/vscode-azurearmtools/issues/1458