Getting an Error : "The expression is involved in a cycle" while running Azure Bicep code

327 views Asked by At

enter image description here

I decompiled json file to bicep file using VS Code. After the decompilation, I am getting the following error:

The expression is involved in a cycle ("virtualNetworks_VNET_DEV_name_SNET_APPDEV01" -> "virtualNetworks_VNET_DEV_name_resource").bicep(BCP080)

Please help me resolve the issue.

Thanks in advance.

1

There are 1 answers

0
Jahnavi On BEST ANSWER

Refer Github issue for the similar error "Expression involved in a cycle" while decompiling from JSON to Bicep.

This error comes when a bicep compiler finds that a parameter or resource is pointing out itself.

To correct it, remove the reference to a resource that is referring itself, as there is no need to do so.

Two ways to remove the error:

  1. Remove the reference as I detailed above and thanks @Thomas for suggesting it.
  2. Alternatively as a workaround, use resourceId() to reference the corresponding symbolic resource and access the resource Id property which is detailed in the given MS Doc.

Here I tried to decompile a sample template into Bicep from Json. The resourcedId function is used in the JSON code to access the Id, as showed.

After decompilation, it was changed to nsg.id and no error was thrown. It fails to operate properly in every case, and you had the same problem. That is why I recommended you use one of the ways I described above.

enter image description here

enter image description here