1
votes

I want to deploy an Azure ressource. The variables used in the template are declared in a dedicated parameter file. However, when deploying the template I'm getting the following error:

New-AzResourceGroupDeployment -ResourceGroupName $resourceGroup -TemplateUri $templateUri -TemplateParameterUri $paramUri

New-AzResourceGroupDeployment : 10:13:17 - Error: Code=InvalidTemplate; Message=Deployment template validation failed: 'The value for the template parameter 'sku' at line '22' and column '16' is not provided. Please see https://aka.ms/arm-deploy/#parameter-file for usage details.'.

"sku" is the parameter and is defined as:

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "sku": {
            "value": {
                "name": "Standard_B1s",
                "tier": "Standard",
                "capacity": 1
            }
        }
    }
}

and it is called/used like this

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "sku": {
            "type": "object"
        }
    },
    "variables": {},
    "resources": [
        {
            "comments": "",
            "type": "Microsoft.Compute/virtualMachineScaleSets",
            "sku": "[parameters('sku')]",
            "name": "SomeName",
            "apiVersion": "2018-06-01",
            "location": "westeurope",
            "scale": null,
            "properties": {}
        }
    ],
    "outputs": {}
}

I'm using the way to call parameters this way in a different template without a problem.

Do some of you spot the error?

1
how do you invoke the template? templates look fine - 4c74356b41
Just edited the question, excuse the obvious oversight: New-AzResourceGroupDeployment -ResourceGroupName $resourceGroup -TemplateUri $templateUri -TemplateParameterUri $paramUri - baouss
interesting, I'm getting the same weird behaviour with a similar template - 4c74356b41
I just replaced the parameter reference with its hard-coded values... I am still getting that error... This should not be possible because there is no reference any more. Does ARM cache the deployment files somehow? And it tries to redeploy some existing cached version? - baouss
I just completely removed and references to that parameter in both files (template and param file), still the same error?! How is this possible - baouss

1 Answers

1
votes

Ok, it's my fault.

I overly simplified the template, and thus left out one crucial piece of information:

I'm using a linked template (to an earlier deployment of an application gateway), and build upon this, adding new resources. This first deployment template also has its own parameter file.

Below is the deployment resource, I'm referencing. I forgot to put in the parametersLink property. So ARM could not lookup the parameter file and provide the argument to "sku" parameter in the first template.

Unfortunately the gateway's template also had a "sku" parameter, so I was erroneously thinking there was an error in my other template. I now name the parameter "skuGateway" and "skuScaleSet" as a lesson-learned.

{
    "apiVersion": "2017-05-10",
    "name": "stack1_gw",
    "type": "Microsoft.Resources/deployments",
    "properties": {
        "mode": "Incremental",
        "templateLink": {
            "uri": "[concat(uri(deployment().properties.templateLink.uri, 'stack1_gw.json'), parameters('containerSasToken'))]",
            "contentVersion": "1.0.0.0"
        },
        "parametersLink": {
            "uri": "[concat(uri(deployment().properties.templateLink.uri, 'stack1_gw.parameters.json'), parameters('containerSasToken'))]",
            "contentVersion": "1.0.0.0"
        }
    }
}