Skip to content

Resource names doesnt support expression validation #1116

@Gijsreyn

Description

@Gijsreyn

Prerequisites

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

Summary

Looking from a Bicep perspective, the following example showcases how to give a name based on a parameter:

param prefix string = 'myapp'
param environment string = 'dev'

resource storage 'Microsoft.Storage/storageAccounts@2023-01-01' = {
  name: '${prefix}${environment}sa'
  location: resourceGroup().location
  sku: {
    name: 'Standard_LRS'
  }
  kind: 'StorageV2'
}

However, trying to do the same in DSC v3 doesn't evaluate the expression:

$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
parameters:
  resourceName:
    type: string
    defaultValue: name
resources:
- name: "[concat('start-', parameters('resourceName'))]"
  type: Microsoft.DSC.Debug/Echo
  properties:
    output:
      hasSvcPrefix: "[concat('test-', parameters('resourceName'))]"

Output:

results:
- metadata:
    Microsoft.DSC:
      duration: PT0.0492017S
  name: '[concat(''start-'', parameters(''resourceName''))]'
  type: Microsoft.DSC.Debug/Echo
  result:
    actualState:
      output:
        hasSvcPrefix: test-name

Steps to reproduce

Run the example from above.

Expected behavior

results:
- metadata:
    Microsoft.DSC:
      duration: PT0.1481929S
  name: start-name
  type: Microsoft.DSC.Debug/Echo
  result:
    actualState:
      output:
        hasSvcPrefix: test-name

Actual behavior

The expression is not evaluated

Error details

Environment data

Name                           Value
----                           -----
PSVersion                      7.5.3
PSEdition                      Core
GitCommitId                    7.5.3
OS                             Microsoft Windows 10.0.26100
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.5

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions