š From a Diagram/Picture to any code, using GitHub Copilot & VS Code
Managing infrastructure in Azure often begins with manually setting up services in the portal. But what if youāve already built a beautiful setup in a resource group and want to replicate it across environments or subscriptions? Thatās where Azure Resource Visualizer, Terraform, and ARM templates come into play.
In this blog, weāll explore how to:
- Export its structure as a visual reference
- Leverage GitHub Copilot and VS Code to streamline the process, to produce a Terraform or an ARM template as Infrastructure-as-Code (IaC)
- Recreate the same infrastructure in another Azure subscription
š“ Please note that the ātranslated codeā wonāt be 100% accurate, and you may need to make minor adjustments, since not all the details of the objects appears in the diagram/picture. However, it will still save you a significant amount of time when writing or translating code.
šø Export the Picture Using Azure Resource Visualizer
- You can use any diagram as an input, not only from Azure Resource Visualizer of course š
- Go to the Azure Portal: https://portal.azure.com
- Navigate to your resource group (
rsg) - In the left menu of the resource group, click on Resource Visualizer
- It auto-generates a visual map of resources and their dependencies
- Click Export (top right corner) ā Choose PNG or SVG
š” While the visual is helpful, it doesnāt export infrastructure code ā for that, continue to Step 2.
š§±Option 1: Translate to ARM Template with GitHub Copilot
Now letās translate the exported picture into an ARM Template.
- Open VS Code
- Make sure the following extensions are installed:
3. Open the Copilot chat:
4. Insert the exported jpg to the chat box and type your request, for example:
Please create an arm template to implement in Azure from the attached picture
5. The output will contain the full ARM template for a quick implementation in Azure:
6. Now just copy the code and use it for IAC or deploy it in another subscription.
š¦Option 2: Translate to a Terraform code with GitHub Copilot
Now letās translate the exported picture into a Terraform code.
- Open VS Code
- Make sure the following extensions are installed:
- ā Terraform
- ā GitHub Copilot
3. Open the Copilot chat:
4. Insert the exported jpg to the chat box and type your request, for example:
Please create a Terraform script to implement in Azure from the attached picture
5. The output will contain the Terraform code for a quick implementation in Azure:
6. Now just copy the code and use it for IAC or deploy it in another subscription.
š»Option 3: Translate to CLI code with GitHub Copilot
Now letās translate the exported picture into a CLI code.
- Open VS Code
- Make sure the following extensions are installed:
3. Open the Copilot chat:
4. Insert the exported jpg to the chat box and type your request, for example:
Please create a cli script to implement in Azure from the attached picture
5. The output will contain the full CLI code for a quick implementation in Azure:
6. Now just copy the code and use it for IAC or deploy it in another subscription.
š Bonus: Helpful Tools
- Azure Terrafy (aztfy) ā Converts existing Azure resources into Terraform.
- ARM-to-Terraform converters ā ARM2TF or arm2tf tool.
- VS Code + Terraform plugin ā for comfortable IaC editing.
š§© Conclusion: Copilot + Azure = IaC Superpowers
GitHub Copilot is a powerful productivity enhancer when translating Azure infrastructure into reusable code ā especially when working with outputs from the Azure Resource Visualizer and Export Template features.
While Azure doesnāt natively convert visuals into Terraform, combining Copilotās AI code generation with your exported ARM templates bridges that gap. Copilot helps by:
- Autocompleting Terraform and ARM template syntax
- Translating resource definitions faster
- Reducing human error and repetitive typing
- Speeding up the overall Infrastructure-as-Code workflow
That said, Copilot is most effective as a smart assistant, not a replacement for your understanding. You still need to verify dependencies, naming conventions, and resource relationships ā especially in complex Azure environments.
ā Best of both worlds: Use Azureās export capabilities for structure, and let Copilot assist in translating that structure into code you can reuse, version, and scale across subscriptions.
