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

Decompile - Unrecognized top-level resource property 'id' #6279

Open
wsmelton opened this issue Mar 24, 2022 · 6 comments
Open

Decompile - Unrecognized top-level resource property 'id' #6279

wsmelton opened this issue Mar 24, 2022 · 6 comments

Comments

@wsmelton
Copy link

Bicep version
Bicep CLI version 0.4.1318 (ee0d808)

Describe the bug
Attempted decompiling this azuredeploy.json from another GitHub repo.

To Reproduce
Downloaded repo and ran `bicep decompile .\azuredeploy.json

Received following output

 > bicep decompile .\azuredeploy.json
WARNING: Decompilation is a best-effort process, as there is no guaranteed mapping from ARM JSON to Bicep.
You may need to fix warnings and errors in the generated bicep file(s), or decompilation may fail entirely if an accurate conversion is not possible.
If you would like to report any issues or inaccurate conversions, please see https://github.com/Azure/bicep/issues.
C:\git\project-stig\.\azuredeploy.json: Decompilation failed with fatal error "[55:15]: Unrecognized top-level resource property 'id'"
@alex-frankel
Copy link
Collaborator

Has this code changed since you filed the issue? I don't see an "id" property anywhere in the template, which would make this error even more confusing if you can still reproduce.

@wsmelton
Copy link
Author

wsmelton commented Mar 30, 2022

It has not. The link points the exact version I'm testing on that still exist.

I couldn't find any ID property either so not sure why it spits out the warning.

@alex-frankel
Copy link
Collaborator

We are not sure what is happening here, but will investigate. Thanks for providing the repro.

@brwilkinson
Copy link
Collaborator

brwilkinson commented Apr 8, 2022

From reviewing this template, I can see that it contains several nested deployments.

Curently we don't support the bicep decompile for this scenario.

module imageDefinitionsDeploy '?' /*TODO: replace with correct path to [variables('imageDefinitionUrl')]*/ = {

There is also 1 particular item that is now unsupported in Bicep, that will not likely be 'fixed'.

In Bicep you can no longer use a variable to represent the bicep file path used for a Bicep Module.

https://docs.microsoft.com/en-us/azure/azure-resource-manager/bicep/modules#definition-syntax

image

Currently that template does use variables for the nested template deployment paths.

    "imageDefinitionUrl": "[uri(deployment().properties.templateLink.uri, 'nested/imageDefinition.json')]",

In short/summary...

It should be very easy to remediate the issue within this decompile, however it will require some manual work.

  1. Decompile all of the individual templates to their own Bicep files (these will become Modules)
    "workspaceUrl": "[uri(deployment().properties.templateLink.uri, 'nested/workspace.json')]",
    "workspaceDashboardUrl": "[uri(deployment().properties.templateLink.uri, 'nested/dashboard.json')]",
    "managedIdentityUrl": "[uri(deployment().properties.templateLink.uri, 'nested/managedIdentity.json')]",
    "imageGalleryUrl": "[uri(deployment().properties.templateLink.uri, 'nested/imageGallery.json')]",
    "win10mageTemplateUrl": "[uri(deployment().properties.templateLink.uri, 'imageTemplates/windows10Evd.json')]",
    "srv2016imageTemplateUrl": "[uri(deployment().properties.templateLink.uri, 'imageTemplates/windows2016.json')]",
    "srv2019imageTemplateUrl": "[uri(deployment().properties.templateLink.uri, 'imageTemplates/windows2019.json')]",
  1. update the Bicep file that is decompiled to refence the new bicep files that you decompiled.

    from:

    module imageDefinitionsDeploy '?' /*TODO: replace with correct path to [variables('imageDefinitionUrl')]*/ = {

    to:

    module imageDefinitionsDeploy './imageGallery.bicep' = {

@brwilkinson
Copy link
Collaborator

@wsmelton are you able to confirm that the decompile error is related to nested deployments ?

@wsmelton
Copy link
Author

wsmelton commented May 8, 2022

Yes, seems to be the nested deployments.

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

No branches or pull requests

3 participants