Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to make use of derived type properties #15391

Open
Dash opened this issue Oct 22, 2024 · 1 comment
Open

Unable to make use of derived type properties #15391

Dash opened this issue Oct 22, 2024 · 1 comment
Labels
Needs: Author Feedback Awaiting feedback from the author of the issue

Comments

@Dash
Copy link

Dash commented Oct 22, 2024

Bicep version
0.30.23 (ec3612e)

Describe the bug
I am trying to make use of the functionality added in PR #13047, but it doesn't seem to work and I get:

Error BCP391: Type member access is only supported on a reference to a named type. [https://aka.ms/bicep/core-diagnostics#BCP391]

To Reproduce
Steps to reproduce the behavior:

  1. Create a new bicep file following the syntax described, e.g.
param baseName string = resourceGroup().name
param location string = resourceGroup().location
param name string = '${baseName}-nsg'

param securityRules resource<'Microsoft.Network/networkSecurityGroups@2023-09-01'>.properties.securityRules

resource nsg 'Microsoft.Network/networkSecurityGroups@2023-09-01' = {
  name: name
  location: location
  properties: {
    securityRules: securityRules
  }
}
  1. Run az bicep build -f myfile.bicep
  2. Witness the errors:
testy.bicep(5,21) : Error BCP391: Type member access is only supported on a reference to a named type. [https://aka.ms/bicep/core-diagnostics#BCP391]
testy.bicep(11,20) : Error BCP062: The referenced declaration with name "securityRules" is not valid. [https://aka.ms/bicep/core-diagnostics#BCP062]

Additional context
Visual Studio Code extension also doesn't like this syntax.

@jeskew
Copy link
Contributor

jeskew commented Oct 23, 2024

@Dash Resource-derived types are an experimental feature and need to be explicitly enabled. Try adding a bicepconfig.json file in the same directory that looks like this:

{
    "experimentalFeaturesEnabled": {
        "resourceDerivedTypes": true
    }
}

@stephaniezyen stephaniezyen added Needs: Author Feedback Awaiting feedback from the author of the issue and removed Needs: Triage 🔍 labels Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Author Feedback Awaiting feedback from the author of the issue
Projects
Status: Todo
Development

No branches or pull requests

3 participants