Forum Discussion
akin_k
Jul 16, 2024Copper Contributor
Copying template.json from Export Template and deploy in bicep
I have a question, i want to deploy my resources (already created on Azure Portal) on my Azure Dev Ops Repo. My question is: is it legit to take the template.json from Export Template and then convert it into Bicep and then deploy with some changes on Azure Dev Ops?
Thank you very much!
- I am also generally in favour of building things up from the base. The template.json file can help you with this and simplify the start.
- Matthias-BraunBrass Contributor
Hi akin_k,
first to your actual question and then to your comment.
It's not as simple as you imagine. Unfortunately, I have to tell you that you should familiarise yourself with the topic of bicep if you want to provide your resources about it.
For examample: Fundamentals of Bicep - Training | Microsoft Learn
Here’s a high-level overview of the process:
- Export the ARM Template: Use the Azure portal to export the ARM template (template.json) of your existing resources.
- Convert to Bicep: Use the Bicep CLI or Visual Studio Code to decompile the ARM template JSON to a Bicep file. This process may require some manual adjustments to ensure the Bicep file adheres to best practices.
- Modify the Bicep File: Make the necessary changes to the Bicep file to suit your deployment needs.
- Deploy with Azure DevOps: Set up a CI/CD pipeline in Azure DevOps to deploy the Bicep file. You can use the Azure Resource Group Deployment task or Azure CLI task within your pipeline for deployment.
Remember, while the export process attempts to create a usable template, most exported templates require some modifications before they can be used for deployment.
I hope this helps.
Now to your comment, which I don't think is polite.
Sometimes it takes a few days for someone to answer a question. Not everyone has the dedicated know-how or the time to answer. This is a community and we all have enough other things to do...
Best,
Matthias
- akin_kCopper Contributorthank you very much, yeah i thought my question was not good enough and often people then ignore!
But what things should be modified? Is it not better than to start from scratch especially for things like azure functions? It would be not so much time-consuming?- latzoxCopper ContributorEven though it's late, I hope this comment is still useful for you or anyone else who comes across this post.
The ARM to Bicep conversion process is quite effective, but it isn’t flawless. Some complex constructs or specific resource configurations in ARM JSON may not convert smoothly into Bicep. You might encounter:
Syntax errors or warnings that require addressing after conversion.
Certain features, such as complex nested deployments, may not decompile correctly and might need manual intervention to fix.
Exported ARM templates may also contain hidden dependencies that aren’t immediately obvious, and these can be carried over directly into the Bicep code. This makes it more challenging to refactor and reorganize the template effectively, particularly when extracting reusable modules.
Hope this helps.
- akin_kCopper Contributorwhy i did not receive any help?