Azure / bicep

Bicep is a declarative language for describing and deploying Azure resources
MIT License
3.23k stars 748 forks source link

Cant decompile Service Bus template exported from Azure Portal #3590

Open afscrome opened 3 years ago

afscrome commented 3 years ago

Bicep version Bicep CLI version 0.4.63 (7ebed03284)

Describe the bug After exporting the ARM json template from a service bus resource in the portal, I was unable to decompile it to bicep due to several errors about The property "location" is not allowed on objects of type ...

Not sure if this is a bug with the bicep decompiler / api spec not allowing this property, or with the azure template generation incorrectly including the location properties.

A selection of those errors are below

> az bicep decompile --file .\serviceBus.json 

C:\Temp\serviceBus.bicep(89,3) : Error BCP037: The property "location" is not allowed on objects of type "Microsoft.ServiceBus/namespaces/AuthorizationRules". Permissible properties include "dependsOn".
C:\Temp\serviceBus.bicep(115,3) : Error BCP037: The property "location" is not allowed on objects of type "Microsoft.ServiceBus/namespaces/networkRuleSets". Permissible properties include "dependsOn".
C:\Temp\serviceBus.bicep(126,3) : Error BCP037: The property "location" is not allowed on objects of type "Microsoft.ServiceBus/namespaces/queues". Permissible properties include "dependsOn".
C:\Temp\serviceBus.bicep(1009,3) : Error BCP037: The property "location" is not allowed on objects of type "Microsoft.ServiceBus/namespaces/topics". Permissible properties include "dependsOn".
C:\Temp\serviceBus.bicep(1117,3) : Error BCP037ac: The property "location" is not allowed on objects of type "Microsoft.ServiceBus/namespaces/topics/subscriptions". No other properties are allowed.
C:\Temp\serviceBus.bicep(4008,3) : Error BCP037: The property "location" is not allowed on objects of type "Microsoft.ServiceBus/namespaces/topics/subscriptions/rules". No other properties are allowed.

To Reproduce

  1. Export an ARM template of a service bus resource in the Azure portal
  2. Attempt to decompile that template to bicep.

Additional context After commenting out all location properties (except that on the root Microsoft.ServiceBus/namespaces resource), I was able to successfully decompile the template.

anthony-c-martin commented 3 years ago

I think this is actually a combination of two bugs/limitations:

The decompiler doesn't do any of its own filtering out based on type information, as this could be potentially destructive if we have type definition inaccuracies.

Also note that #3000 will result in these being warnings rather than errors with the next Bicep release.

afscrome commented 3 years ago

@anthony-c-martin Are those bugs / limitations tracked elsewhere? If so, do you want to close this issue in favour of those.

alex-frankel commented 3 years ago

This should now be a warning in 0.4.412. We'll leave this open to track the swagger fix.