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

Bicep to Arm conversion generates invalid json for dictionary object. #11954

Closed
dxk3355 opened this issue Sep 25, 2023 · 2 comments
Closed

Bicep to Arm conversion generates invalid json for dictionary object. #11954

dxk3355 opened this issue Sep 25, 2023 · 2 comments
Labels
Needs: Author Feedback Awaiting feedback from the author of the issue Needs: Triage 🔍

Comments

@dxk3355
Copy link

dxk3355 commented Sep 25, 2023

Bicep version
Unknown, Visual Studio Code plugin. Example commands do not work.

Describe the bug
Using the Dictionary object example on https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/loops

param nsgValues object = {
  nsg1: {
    name: 'nsg-westus1'
    location: 'westus'
  }
  nsg2: {
    name: 'nsg-east1'
    location: 'eastus'
  }
}

resource nsg 'Microsoft.Network/networkSecurityGroups@2020-06-01' = [for nsg in items(nsgValues): {
  name: nsg.value.name
  location: nsg.value.location
}]

I get invalid JSON when I use the Build ARM Template in VS Code. With the error

Template validation failed: The template resource '[items(parameters('nsgValues'))[copyIndex()].value.name]' at line '27' and column '5' is not valid: The template function 'items' is not valid. Please see https://aka.ms/arm-template-expressions for usage details.. Please see https://aka.ms/arm-template-expressions for usage details.arm-template (validat

To Reproduce
Create a new test.bicep file in VS Code with the ARM and Bicep extensions from Microsoft installed. Copy and paste the above code from the Dictionary object example on https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/loops
Save the file
Right click on the test.bicep file
Select 'Build ARM Template'
Open the test.json that is generated.
You will see an error from the ARM extension indicating that the template is invalid.

Additional context
The template will also not pass validation in Azure.

@github-project-automation github-project-automation bot moved this to Todo in Bicep Sep 25, 2023
@dxk3355 dxk3355 changed the title Bicep to Arm conversion generate invalid ARM json for Dictionary object. Bicep to Arm conversion generates invalid json for dictionary object. Sep 25, 2023
@anthony-c-martin
Copy link
Member

anthony-c-martin commented Sep 25, 2023

@dxk3355 I was able to validate & deploy the Bicep file you provided.

I think this is just a gap in the validation provided by https://github.com/Microsoft/vscode-azurearmtools.

@StephenWeatherford StephenWeatherford added the Needs: Author Feedback Awaiting feedback from the author of the issue label Sep 27, 2023
@StephenWeatherford
Copy link
Contributor

Agreed. Moving to vscode-azurearmtools.

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 Needs: Triage 🔍
Projects
Archived in project
Development

No branches or pull requests

3 participants