Edit

Share via


Quickstart: Deploy your application to Azure with agent mode in GitHub Copilot for Azure

In this quickstart, you learn how to use agent mode in GitHub Copilot for Azure to bring your existing application to Azure. It demonstrates how agent mode helps you define Azure infrastructure, deploy your application to Azure, and create a CI/CD pipeline.

GitHub Copilot for Azure supports two modes:

  • Ask mode allows you to learn about your deployed Azure resources and about Azure in general using the latest information published to Microsoft Learn. It might provide instructions or even source code, but you take action or edit files yourself.
  • Agent mode allows you to command GitHub Copilot to take action in your project, including creating and editing files, executing commands in the terminal window, and so on.

Prerequisites

For complete setup instructions, see the Get started article. Make sure that you have the following items:

Important

GitHub Copilot isn't included in Visual Studio Subscriptions and is a separate subscription managed by GitHub. For questions regarding GitHub Copilot subscriptions and Support, see Individual Subscriptions or Business subscriptions.

Define Azure infrastructure for your application

In this section, use GitHub Copilot agent mode to create Bicep deployment files and an azd template for the application.

  1. Open your existing application in Visual Studio Code.

    If you want to follow along with this tutorial, you can clone the following repo from GitHub to your local computer:

    git clone https://github.com/Azure-Samples/storage-blob-upload-from-webapp.git
    
  2. In Visual Studio Code, on the Title Bar, select the Open Chat icon (the GitHub Copilot logo) to open the chat pane in the Secondary side bar. Select Agent under the chat text box.

    Screenshot that shows the GitHub Copilot chat pane.

    To start a new chat session, select the plus icon (+) on the pane's title bar.

  3. In the chat text box at the bottom of the pane, type the following prompt. Then select Send (paper airplane icon) or select Enter on your keyboard.

    Help me deploy my project to Azure
    

    Copilot Agent analyzes the project, recommend Azure services, and generate Bicep files. You might see a response like the following example.

    Screenshot of the GitHub Copilot chat pane evaluating your project to recommend resources.

    Important

    Each time GitHub Copilot for Azure answers the prompt the response's wording is different due to how large language models (LLMs) generate responses. It's possible your experience might vary from this article. Take the time to read GitHub Copilot's responses and choose the correct course of action. If you're unsure how to proceed, ask GitHub Copilot what it intends to do and why.

    Select Continue and Copilot Agent finishes analyzing the project and starts to generate the necessary files. You might see a response like the following example.

    Screenshot of the GitHub Copilot chat pane creating a directory for the bicep files.

    Select Continue and Copilot generates the necessary files for deployment. You might see a few files generated in the project and a response like the following example.

    Screenshot of the GitHub Copilot chat pane generating the bicep files.

Deploy your application

  1. Next, Copilot agent wants to run a predeployment check.

    Screenshot of the GitHub Copilot chat pane checking files and local environment to ensure they're ready for azd up.

  2. Select Continue and Copilot agent checks if the app is ready to deploy with azd. If there's an issue, Copilot agent fixes it and checks again, like in the following example.

    Screenshot of the GitHub Copilot chat pane checking files fixing issues before running azd up.

  3. Once the predeployment check passes, Copilot agent continues with the deployment process. It checks for a few dependencies first. You might see a response like the following example.

    Screenshot of the GitHub Copilot chat pane checking dependencies before running azd up.

  4. Select Continue for each dependency check. Copilot agent asks if we want to proceed with deployment. You might see a response like the following example.

    Screenshot of the GitHub Copilot chat pane asks if it should proceed with deployment.

  5. Select Continue. Copilot agent should open the terminal on run azd up on your behalf. Follow the required steps in the terminal.

    You might encounter an error with .NET version; Copilot picks it up and generates a fix for it. You might see a response like the following example.

    Screenshot of the GitHub Copilot chat pane informing about the need to upgrade to .NET 8.

  6. Select Continue. Copilot agent deploys the app successfully. You might see a response like the following example.

    Screenshot of the GitHub Copilot chat pane informing about deployment success and next steps.

  7. If any errors were encountered during the deployment process, Copilot agent mode can also fix the errors and redeploy the application.

Tips

  • Use Claude 3.5 Sonnet or Claude 3.7 Sonnet for better results.

  • Make sure the following GitHub Copilot for Azure tools are selected in the GitHub Copilot tools list:

    • @azure recommend service config
    • @azure check pre-deploy
    • @azure AZD Up (Deploy)
    • @azure check app status for azd deployment
    • @azure config deployment pipeline
    • @azure check region availability
    • @azure check quota availability

    Screenshot of the selected GitHub Copilot for Azure tools.

    To view a list of tools that are available to your prompts, select the Select tools... button in the chat text box.