skip to Main Content

I’m a beginner on Azure DevOps and I’m trying to create a CI pipeline for an simple ARM Template. So I have this file (test_template.json):

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "storageAccounts_dqed01dls_name": {
            "defaultValue": "dqed01als",
            "type": "String"
        },
        "virtualNetworks_dpm01_d_vnet_externalid": {
            "defaultValue": "/subscriptions/xxx1234/resourceGroups/dpm01-vnets-d-rg/providers/Microsoft.Network/virtualNetworks/dpm01-d-vnet",
            "type": "String"
        },
        "Environment": {
            "value": "Acc",
            "type": "string"
        }
    },
    "variables": {},
    "resources": [
        {
            "type": "Microsoft.Storage/storageAccounts",
            "apiVersion": "2021-09-01",
            "name": "[parameters('storageAccounts_dqed01dls_name')]",
            "location": "westeurope",
            "tags": {
                "CBSPProduct": "Storage 4.0.1",
                "AppName": "DQEM",
                "Billing code": "XX000",
                "Business Application CI": "XX00546",
                "CIA": "001",
                "ContactMail": "[email protected]",
                "ContactPhone": "+390000000",
                "Environment": "[parameters('Environment').value]",
                "Owner": "[email protected]",
                "Provider": "PTV_Azure"
                
(...)

And also this parameter file (test_parameters.json), which I have no idea why it exists because this parameters are also defined in the ARM template above

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "storageAccounts_dqed01dls_name": {
            "value": "dqed01dls"
        },
        "virtualNetworks_dpm01_d_vnet_externalid": {
            "value": "/subscriptions/xxx1234/resourceGroups/dpm01-vnets-d-rg/providers/Microsoft.Network/virtualNetworks/"
        },
        "Environment": {
            "value": "Acc"
        }
    }
}

Then, I run this YAML pipeline:

# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml

trigger:
- "*"

parameters:
- name: Environment
  displayName: Environment
  type: string
  default: ubuntu-latest
  values:
  - Dev
  - Acc
  - Prod

stages:
  - stage: test
    jobs:
      - job: 'validateandtest'
        pool:
          vmimage: windows-latest
        steps:
        - task: AzureResourceManagerTemplateDeployment@3
          inputs:
            deploymentScope: 'Resource Group'
            azureResourceManagerConnection: 'dpm01-devops-a-rg'
            subscriptionId: 'xxx1234'
            action: 'Create Or Update Resource Group'
            resourceGroupName: 'dpm01-devops-a-rg'
            location: 'West Europe'
            templateLocation: 'Linked artifact'
            csmFile: '$(Build.SourcesDirectory)/pipeline/test_template.json'
            deploymentMode: 'Incremental'

And I get this error:

##[error]Deployment template validation failed: 'The template parameter 'Environment' at line '1' and column '484' is not valid. The parameter value must be null. Please see https://aka.ms/arm-template/#parameters for usage details.'.

The idea was to pass Environment as a parameter to the ARM template. Since it didn’t work, I hardcoded it, but get this error and I don’t understand why it must be null.

2

Answers


  1. Look at line 14 of your ARM template:

            "Environment": {
    ------> "value": "Acc",
                "type": "string"
            }
    

    Look at one of the other parameters:

            "virtualNetworks_dpm01_d_vnet_externalid": {
    ------> "defaultValue": "/subscriptions/xxx1234/resourceGroups/dpm01-vnets-d-rg/providers/Microsoft.Network/virtualNetworks/dpm01-d-vnet",
                "type": "String"
            },
    

    You are specifying value, not defaultValue. I’m kind of surprised that’s syntactically valid, but that’s probably where the error is coming from: You are specifying a parameter value in the template itself.

    Login or Signup to reply.
  2. There is no value attribute under parameter, according to the documentation. Make sure you provide defaultValue unless you want to have it set in CLI.
    Azure documentation

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search