Export existing Azure resources to Bicep

With the new release of Bicep (v0.4.1124) it is now possible to export existing Azure resources to Bicep code. This means you do not have to export your resources to ARM and then do a decompile.

Exporting your existing resources is very easy and can be done within Visual Studio Code.

Get Resource ID

To be able to export the resource to Bicep you need to have the resource ID of the resource. You can find this resource very easily by opening the resource within Azure and opening the “properties” blade. One of the properties in this blade is the Resource ID

Export Bicep

To export the template follow these steps:

  1. Open Visual Studio Code
  2. Open an existing “bicep” file or create a new one.
  3. Press ctrl+shift+p or open the command pallet.
  4. Search for “Bicep” and select the option “Insert resource”.
  5. This will ask for the resource ID. Paste the resource ID and press enter.
  6. The resource is now imported within your Bicep file.

6 Replies to “Export existing Azure resources to Bicep”

  1. Good information, In my case nothing is happening. bicep file stays blank.
    I have logged into Azure portal via cli and set account subscription to correct one.
    Could you point out what could be missing ?

    1. I don’t think that you are missing something if you have logged in into the build in console of for example visual studio code. Sometimes a good configuration of your config file helps.

    2. Same here. Installed the Bicep and Azure Tools extension, signed into Azure CLI and Azure tools with the same account. Verified I have the right subscription selected…

      Insert Resource does not do anything. No error message in the output pane as well.

      1. I also have problems from time to time. If I run into issues I try cleaning out my logged in sessions and then it most of the time works

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.