Skip to content

Encountering error invoking a user defined function in bicep config file #1271

@snehanagendra

Description

@snehanagendra

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest version
  • Search the existing issues.

Summary

Encountering error invoking a user defined function in bicep config file 2025-11-18T18:50:22.719093Z ERROR dsc::subcommand: 380: Parameter input failure: Parser: Unable to parse: [__bicep.upper(parameters('environmentTier'))]

Steps to reproduce

  1. Use this bicep config file
extension dsc
targetScope = 'desiredStateConfiguration'

// Base path for all test keys
@description('Base registry path where results are written')
param basePath string = 'HKEY_LOCAL_MACHINE\\SOFTWARE\\DSCBicepTests'

@description('Environment tier as a tagged union')
param environmentTier 'dev' | 'prod' = 'dev'

func upper(s string) string => toUpper(s)

var environmentTierUpper = upper(environmentTier)

resource f08_types 'Microsoft.Windows/Registry@1.0.0' = {
  keyPath: '${basePath}\\F08.Types.userFunction_upperTier'
  valueName: 'environmentTierUpper'
  valueData: { String: environmentTierUpper }
}

output testUserFunctionEnvironmentTierUpper string = environmentTierUpper
  1. Apply the bicep config via DSC
  2. Observe error
  3. Providing the generated json for debugging purposes
{
  "$schema": "https://aka.ms/dsc/schemas/v3/bundled/config/document.json",
  "languageVersion": "2.2-experimental",
  "contentVersion": "1.0.0.0",
  "metadata": {
    "_EXPERIMENTAL_WARNING": "This template uses ARM features that are experimental. Experimental features should be enabled for testing purposes only, as there are no guarantees about the quality or stability of these features. Do not enable these settings for any production usage, or your production environment may be subject to breaking.",
    "_EXPERIMENTAL_FEATURES_ENABLED": [
      "Enable defining extension configs for modules"
    ],
    "_generator": {
      "name": "bicep",
      "version": "0.36.177.2456",
      "templateHash": "2201566858413804903"
    }
  },
  "functions": [
    {
      "namespace": "__bicep",
      "members": {
        "upper": {
          "parameters": [
            {
              "type": "string",
              "name": "s"
            }
          ],
          "output": {
            "type": "string",
            "value": "[toUpper(parameters('s'))]"
          }
        }
      }
    }
  ],
  "parameters": {
    "basePath": {
      "type": "string",
      "defaultValue": "HKEY_LOCAL_MACHINE\\SOFTWARE\\DSCBicepTests",
      "metadata": {
        "description": "Base registry path where results are written"
      }
    },
    "environmentTier": {
      "type": "string",
      "allowedValues": [
        "dev",
        "prod"
      ],
      "defaultValue": "dev",
      "metadata": {
        "description": "Environment tier as a tagged union"
      }
    }
  },
  "variables": {
    "environmentTierUpper": "[__bicep.upper(parameters('environmentTier'))]"
  },
  "extensions": {
    "dsc": {
      "name": "DesiredStateConfiguration",
      "version": "0.1.0"
    }
  },
  "resources": {
    "f08_types": {
      "extension": "dsc",
      "type": "Microsoft.Windows/Registry",
      "apiVersion": "1.0.0",
      "properties": {
        "keyPath": "[format('{0}\\F08.Types.userFunction_upperTier', parameters('basePath'))]",
        "valueName": "environmentTierUpper",
        "valueData": {
          "String": "[variables('environmentTierUpper')]"
        }
      }
    }
  },
  "outputs": {
    "testUserFunctionEnvironmentTierUpper": {
      "type": "string",
      "value": "[variables('environmentTierUpper')]"
    }
  }
}```

### Expected behavior

```console
DSC is able to invoke the user defined function

Actual behavior

Encountering error invoking a user defined function in bicep config file `2025-11-18T18:50:22.719093Z ERROR dsc::subcommand: 380: Parameter input failure: Parser: Unable to parse: [__bicep.upper(parameters('environmentTier'))]`

Error details

Encountering error invoking a user defined function in bicep config file `2025-11-18T18:50:22.719093Z ERROR dsc::subcommand: 380: Parameter input failure: Parser: Unable to parse: [__bicep.upper(parameters('environmentTier'))]`

Environment data

Name                           Value
----                           -----
PSVersion                      7.5.4
PSEdition                      Core
GitCommitId                    7.5.4
OS                             Microsoft Windows 10.0.22621
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Version

dsc 3.2.0-preview.8

Visuals

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions