Over two years ago, I wrote about GitHub Copilot for the first time. Back then, it was powered by OpenAI Codex models, not the models we know today. GitHub Copilot has come a long way since then, where we now have frontier models such as GPT-4.1 and Sonnet 4, agent mode, extensions, and GitHub Copilot Chat.
Using GitHub Copilot for Infrastructure as Code generation is already impressive, but with the GitHub Copilot for Azure extension, it’s even better than before.
In this blog post, you will learn about the GitHub Copilot for Azure extension and see a few examples of how to use it in your day-to-day work with Azure Bicep.
01-09-2025 Blog update: Some MCP tools are renamed or moved to other extensions, such as Bicep MCP or Azure MCP. I have added new tools that do the same, but have different names.
What is GitHub Copilot for Azure?
GitHub Copilot for Azure is an extension for GitHub Copilot, available in Visual Studio Code. You can make full use of its potential by using agent mode. When you refer to the @azure participant, you can let the agent automatically complete tasks in Azure for you, or you can chat with it in “read-only” ask mode. For example, you can ask about costs or inquire about your environment.
Besides those Azure-related actions, it can also help with writing Azure Bicep. By adding the @azure participant, you’ll get much better responses, as it validates the Azure Bicep code before returning the actual result. You will learn more about the process from prompt to code in the high-level overview below.
GitHub Copilot for Azure supports the following GitHub Copilot modes:
- Ask mode (readonly mode): This mode allows you to ask questions about your Azure environment or learn best practices for Azure Bicep. Ask mode will not implement features for you, but it can return code snippets that you can copy and paste into your editor.
- Agent mode: This mode allows GitHub Copilot to create new or update existing Bicep files and insert implementation-ready Bicep snippets into a template file. GitHub Copilot in agent mode can also perform code searches, execute CLI commands (for example, to create a new Bicep template file), and more. It also has access to many other tools.
You can download the GitHub Copilot for Azure extension for free! On this page, you can also see the extensive list of tools the extension supports, or you can use ask mode and ask which tools are supported:
High-level overview
The image below shows a high-level overview of what happens when you interact with GitHub Copilot for Azure, from prompt to output:

- A user (prompter) writes a prompt and adds the
@azureparticipant. Also, the mode should be set to agent. - Because agent mode is selected, it has access to many Azure tools. These tools are very useful, as they directly impact the quality of the code generation. The tools that are called in the high-level overview include:
- #azure_get_deployment_best_practices: Returns a list of best practices to follow when deploying to Azure or preparing an application for deployment to Azure.
- #azure_get_schema_for_Bicep: Provides the schema for the most recent
apiVersionof an Azure resource, useful when creating or modifying resources in a Bicep template. In this case, for Azure Key Vault. - Access to many more tools, such as GitHub MCP tools. If you want to add a specific tool, refer to it via
#e.g.#get_issue.
- Finally, the agent combines all the information retrieved from the tool calls and generates Bicep code. This code is validated against the schema and follows best practice principles.
Examples
The examples below show how you can leverage GitHub Copilot for Azure to create Infrastructure as Code using agent mode in Visual Studio Code. We start with the first example: from natural language to Infrastructure as Code.
Example 1: From natural language to Infrastructure as Code
In this example, the model is instructed to behave as an Azure Cloud Engineer specialising in Azure Bicep. Additionally, it is asked to create a Bicep template that includes an Azure Key Vault resource, along with the required resources to enable a private endpoint.
In the output video, you can see that the agent calls tools to retrieve the schemas of the resources it creates and fetches Azure Bicep best practices before generating the template.
Prompt
@Azure Act as an Azure Cloud Engineer with a specialisation on Azure Bicep. Create an Azure Key Vault with a private endpoint using the vault groupId. Add a parameter to point to an existing virtual network and subnet. Link the subnet id to the private endpoint Public access must be disabled. Also, create the private DNS zone for the key vault. Ignore tags, and do not use access policies for access to the key vault.
Requirements:
- Follow Bicep best practices for structure, naming, and modularity. Add the contents to the main.bicep.
- Follow the naming convention
<resource abbreviation><environment><function> - Use the latest API version
- Prefix parameters with 'par', variables with 'var', resources with 'res' and outputs with 'out'
- Use
bicepparamto link the parameter file withmain.bicep. Do not give parameters in themain.bicepfile a default value. - Focus on the Bicep and Bicepparam files. Do not create markdown files.
Tools used
The tools used are implicit in this case, but if you assign them explicitly, these are the tools that would be used when referring explicitly:
- #get_bicep_best_practices
- #bicepschema
Output
Example 2: From ClickOps to Infrastructure as Code
In this example, the model is asked to convert a proof of concept, which was originally created using ClickOps, into Infrastructure as Code. With the built-in tools from the GitHub Copilot for Azure extension, it’s possible to look up resources within a resource group.
In the output video, you can see that the agent calls tools to retrieve the schemas of the resources it creates and fetches Azure Bicep best practices before generating the template.
Prompt
@Azure Act as an Azure Cloud Engineer with a specialisation on Azure Bicep. I have created a proof of concept in the resource group rg-managed-devops-pools via the Azure portal (using ClickOps) in subscription Visual Studio Enterprise Subscription.
Generate the Azure Infrastructure as Code using Azure Bicep with the following requirements:
- All resource definitions should go in a mdp.bicep file.
- Do not assign default values to parameters in mdp.bicep; instead, define values separately in a main.bicepparam file.
- Follow Bicep best practices for structure, naming, and modularity.
- Focus on the Bicep and Bicepparam files. Do not create markdown files
Tools used
The tools used are implicit in this case, but if you assign them explicitly, these are the tools that would be used when referring explicitly:
- #azure_query_azure_resource_graph
- #get_bicep_best_practices
- #bicepschema
Output
Example 3: Mix in some other MCP servers
In this example, a GitHub issue is queried using the remote GitHub MCP server. The issue contains the context for what needs to be implemented. Instead of copying and pasting, you can add additional tools outside the GitHub Copilot for Azure toolset.
In this case, the #get_issue tool is used to retrieve the context dynamically, and the prompt also includes some requirements, such as following Bicep best practices.

Prompt
@Azure Act as an Azure Cloud Engineer with a specialisation on Azure Bicep. Implement the requested configuration found in GitHub Issue #1 in repository johnlokerse/GitHubPlayground. Do not create a new virtual network/subnet resource, but add a parameter like parVirtualNetworkId or parSubnetId.
Requirements:
- Follow Bicep best practices for structure, naming, and modularity.
- Follow the naming convention
<resource abbreviation><environment><function> - Use the latest API version
- Prefix parameters with 'par', variables with 'var', resources with 'res' and outputs with 'out'
- Use
bicepparamto link the parameter file withmain.bicep. Do not give parameters in themain.bicepfile a default value. - Focus on the Bicep and Bicepparam files. Do not create markdown or yaml files.
Tools used
The tools used are implicit in this case, but if you assign them explicitly, these are the tools that would be used when referring explicitly:
- #get_issue – This tool comes from the remote GitHub MCP server and retrieves context from an issue in a specific repository.
- #get_bicep_best_practices
- #bicepschema
Output
Example 4: From High-level design to Infrastructure as Code
Lastly, in this example, a high-level design for how the Azure Key Vault should be implemented is uploaded as context in GitHub Copilot. Additionally, extra context is added in the prompt so GitHub Copilot knows what to do. If you’re a more visual person, this approach can be very helpful! Your mileage may vary with more complex designs.
The following high-level design is used:

Prompt
@Azure Act as an Azure Cloud Engineer with a specialisation on Azure Bicep. Implement the high-level design of the Azure Key Vault and the required components to make it private.
Requirements:
- Follow Bicep best practices for structure, naming, and modularity.
- Follow the naming convention
<resource abbreviation><environment><function> - Use the latest API version
- Prefix parameters with 'par', variables with 'var', resources with 'res' and outputs with 'out'
- Use
bicepparamto link the parameter file withmain.bicep. Do not give parameters in themain.bicepfile a default value. - Focus on the Bicep and Bicepparam files. Do not create markdown or yaml files.
Tools used
The tools used are implicit in this case, but if you assign them explicitly, these are the tools that would be used when referring explicitly:
- #bestpractices
- #get_bicep_best_practices
- #bicepschema
Output
Tips
I want to share some tips to improve the outcome of GitHub Copilot for Azure in agent mode:
- Choose the right model for your task. For example:
- Do you want Infrastructure as Code explained to you, are you adding comments to code, or do you need to generate documentation about Infrastructure as Code? For these tasks, GPT-4.1 might be a great fit.
- Do you need multi-step reasoning or are you working on complex refactoring of Infrastructure as Code? For these tasks, premium models such as Claude Sonnet 4 can be a great fit.
- Be thoughtful with your prompts. Add a role, for example, “You are an Azure Bicep expert” or “Act as an Azure Cloud expert with a specialisation in Azure Bicep.” Add rich context, including code examples, schemas, or images. Give GitHub Copilot clear instructions on how to reach your end goal.
- Make use of custom instructions. With custom instructions, you can define guidelines or rules for tasks like code generation, code reviews, and generating Git commit messages.
Conclusion
These are a few examples on how you can use GitHub Copilot for Azure to enhance Infrastructure as Code generation. This extension is not only focused on Azure Bicep, but you can also let it generate Terraform for you.
While the code generation is not always perfect, it’s a great kickstart for projects, or for troubleshooting or to chat against your Azure infrastructure. I have walked in to small issues such as not having the latest API version of resource.
If you work with Azure and write Infrastructure as Code regularly, this extension is a must-have!
01-09-2025 Blog update: Some MCP tools are renamed or moved to other extensions, such as Bicep MCP or Azure MCP. I have added new tools that do the same, but have different names.
