3

I'm in the process of creating bicep files for our current Azure resources. Is there a way to generate a bicep file from an existing azure resource, say a storage account or an app service?

SamIAm
  • 2,241
  • 6
  • 32
  • 51

1 Answers1

5

You should be able to do it. You will need to use the ARM template for the resource though. Once you have it, you can use Bicep CLI to decompile the template.

From this link:

az bicep decompile --file main.json

Other alternative would be to use Bicep Playground which can also take an ARM template JSON and give you a Bicep file.

Gaurav Mantri
  • 128,066
  • 12
  • 206
  • 241
  • 1
    Ah ya, it looks like we can only export the ARM template and then migrate it using the az bicep decompile command. Going to add https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/migrate as a comment too and will accept the answer when allowed. – SamIAm Sep 28 '21 at 00:28
  • You can decompile ARM templates directly in VS Code: Install the Bicep extension, access the Command Palette and type 'decompile'. While your ARM template is open in VS Code, select the 'Decompile into Bicep' command and it will generate a Bicep file in your working directory. Note that the decompilation usually comes with several errors and you will probably have to manually correct it. – fabioklr Nov 17 '22 at 13:36