Skip to content

[BUG] [Experimental] Runtime values in tags and sku #3884

Open

Description

Existing rule

No response

Description of the issue

Originally reported microsoft/PSRule#3425

When using the new experimental feature in Bicep from 0.46.1: https://github.com/Azure/bicep/releases
([Experimental] Runtime values in tags and sku)

resource example 'Microsoft...' = {
   name: 'example'
   location: resourceGroup().location
   sku: {
      name: this.existingResource().?sku.name ?? 'Standard'
   }
   tags: this.existingResource().?tags ?? {}
}

Error messages

Exception calling "GetBicepParamResources" with "2" argument(s): "Unable to expand resources because the source file '/home/vsts/work/1/s/main.bicep' was not valid. The deployment 'root/2026-08-07_14.45' with symbolic name 'hubResourceGroup' failed. An error occurred evaluating expression '[if(parameters('keepExistingTags'), union(coalesce(tryGet(target('full'), 'tags'), createObject()), parameters('tags')), parameters('tags'))]' line 701 at path 'tags'. The function "target" was not found."

Reproduction

Create a bicep file containing the new function:

resource example 'Microsoft...' = {
   name: 'example'
   location: resourceGroup().location
   sku: {
      name: this.existingResource().?sku.name ?? 'Standard'
   }
   tags: this.existingResource().?tags ?? {}
}

Version of PSRule

2.9.0

Version of PSRule for Azure

No response

Additional context

Azure DevOps Microsoft Hosted Agent using the latest version of Linux, running in a PowerShell task using the latest version of bicep (0.46.1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfeature: bicep-languageIssues relating to Bicep language support.feature: pre-flight-expansionIssues relating to expansion of ARM and Bicep.

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions