Skip to content

Commit 3f1070d

Browse files
committed
Add new image for MCP query demonstration in README.md
1 parent f9c5c71 commit 3f1070d

File tree

2 files changed

+177
-7
lines changed

2 files changed

+177
-7
lines changed

Using-GitHub-Copilot-for-Azure-to-Deploy-to-Cloud/README.md

Lines changed: 177 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Managing and deploying cloud resources have historically required developers to switch between various interfaces — integrated development environments (IDEs), command-line tools, Azure Portal dashboards, and third-party CI/CD solutions. This context switching interrupts workflows, multiplies sources of truth, and slows down delivery. With the rise of AI-powered developer tools, a new paradigm is emerging: agentic, autonomous AI collaborators that reside within the IDE, orchestrate across cloud and DevOps environments, and allow developers to command the cloud as simply as they manipulate code.
44

5-
This detailed hands-on workshop will guide developers through harnessing GitHub Copilot Agent Mode in Visual Studio Code (VS Code), integrated with the Azure Model Context Protocol (MCP) server. By the end of this session, you'll be able to set up GitHub Copilot's Coding Agent, connect it to the Azure MCP server for secure, natural language-driven management of cloud infrastructure, and seamlessly complete tasks such as provisioning resources, retrieving secrets, diagnosing issues, and deploying applications from your IDE—directly on top of an existing database API codebase.
5+
This detailed hands-on workshop will guide developers through harnessing GitHub Copilot Agent Mode in GitHub Codespaces (also available to run in VSCode), integrated with the Azure Model Context Protocol (MCP) server. By the end of this session, you'll be able to set up GitHub Copilot's Coding Agent, connect it to the Azure MCP server for secure, natural language-driven management of cloud infrastructure, and seamlessly complete tasks such as provisioning resources, retrieving secrets, diagnosing issues, and deploying applications from your IDE—directly on top of an existing database API codebase.
66

77
This workshop emphasizes how Copilot Agent Mode plus Azure MCP together alleviate pain points like context switching and fragmented workflows, providing developers with a unified, rapid, and secure cloud experience
88

@@ -38,7 +38,7 @@ By the end of this workshop, you will:
3838

3939
**Right click the following Codespaces button to open your Codespace in a new tab**
4040

41-
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/microsoft/Mastering-GitHub-Copilot-for-Paired-Programming)
41+
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/Azure-Samples/msdocs-python-flask-webapp-quickstart)
4242

4343
This hands-on workshop guides you through setting up and using GitHub Copilot Agent Mode in Visual Studio Code, integrated with the Azure MCP server, to streamline cloud resource management and deployment workflows. Participants will start with a prebuilt database API demo and learn how to interact with the Copilot Coding Agent directly from their IDE—assigning cloud-related tasks, provisioning infrastructure, retrieving secrets, diagnosing issues, and deploying applications—all without switching to the Azure Portal or CLI.
4444

@@ -81,25 +81,195 @@ Let's get started!
8181
<img src="./images/004-tools.jpg" alt="View of Azure tools">
8282
</div>
8383

84+
In the above exercises we achieved the following:
85+
- ✅ Configured Copilot Chat and installed the GitHuc Copilot for Azure extension
86+
- ✅ Query the `@Azure` extension and explore features and tools
87+
8488
Now that we have had a tour and configured our environment, we're going to add context and configure the Azure MCP Server.
8589

86-
### Section 2: MCP
90+
### 🗒️ Section 2: Configuring the Azure MCP Server and Using Agent Mode
8791

8892
🎯**Learning Goals**
89-
- Set up the GitHub Copilot Coding Agent and the GitHub Copilot for Azure extensions
90-
- Understand Agent Mode
91-
- Connect to your Azure subscription
93+
- Set up the Azure MCP Server
94+
- Deploy an application to Azure using Agent Mode
9295

9396
The Azure MCP Server is an open implementation of the Model Context Protocol—a standardized interface for exposing external tools, data sources, and actions to AI agents, such as Copilot in Agent Mode. It functions as a middle layer between the agent (client) and your Azure environment, enabling secure, context-aware natural language management of cloud resources.
9497

9598
Key Points:
9699
- Supports broad Azure services: App Configuration, Key Vault, Storage, Cosmos DB, SQL, Kubernetes, Azure Developer CLI (azd), Azure CLI, etc.
97-
- Available as a VS Code Extension or via direct workspace config (see practical setup below)
98100
- Authentication: Uses Azure authentication flow, inheriting RBAC and user scopes
99101
- Command/Tool Abstraction: Each Azure resource operation is exposed as a discrete tool, discoverable and invocable by Copilot for queries and actions
100102
- Security: Enforces permissions, supports HTTPS, can be bound to Entra ID, follows least privilege principles
101103

104+
Now we are going to build a simple Python application in Azure using Flask.
105+
106+
1. The Azure MCP Server extension should have installed with the GitHub Copilot for Azure extension. The Azure MCP Server should start by default. To test this out, in the chat pane type: `List my Azure resources`
107+
108+
<div align="left">
109+
<img src="./images/005-MCPquery.jpg" alt="Output of Azure subscription">
110+
</div>
111+
112+
**Note:** If the MCP server has not been start, you can configure it to do so by opening `settings` in VSCode (or your Codespace) search for `chat.mcp.autostart` and select `newAndOutdated` to automatically start the extension.
113+
114+
2. Once we've confirmed that the MCP server is running, let's build a simple web app and deploy it to Azure. First, create a branch to work from. As we're using Agent mode, we can give Copilot a list of requirements to fully deploy our app. We can tell Copilot exactly what we want to deploy. Give Agent mode a detailed prompt. Copy and paste the prompt below into the chat window:
115+
116+
```
117+
There is a Python web app in this repo. Please help me build and deploy it to Azure.
118+
- Use Azure App Service for hosting.
119+
- Create a new resource group with the name `RG-flaskapp`
120+
- Set up any required Azure resources (App Service Plan basic, Storage, etc.). Use the naming convention of `flaskapp`
121+
- Configure environment variables from my `.env` file as application settings.
122+
- Build the app and deploy it.
123+
- Finally, return the deployed app’s public URL.
124+
```
125+
126+
Copilot will work through the prompt. It will look to understand what was asked, and in the example below, it referenced Azure best practices to help itself better execute the request.
127+
128+
In using Agent mode and the Azure MCP Server, Copilot was able to achieve:
129+
130+
**Build and Deploy Code:**
131+
- Python environment setup
132+
- Installation of application dependencies
133+
- Authentication to Azure using service principal credentials
134+
- Deployment to Azure Web App using the azure/webapps-deploy action
135+
136+
**Azure Resources Deployed:**
137+
- Resource Group: RG-flaskapp
138+
- App Service Plan (Basic tier)
139+
- App Service named flaskapp
140+
- Environment variables configured as App Settings
141+
142+
**Security and Authentication:**
143+
- Requires AZURE_CREDENTIALS secret in GitHub repository
144+
- Uses service principal authentication to Azure
145+
- Deployment happens in a 'Production' environment with URL tracking
146+
147+
3. Next, let’s take it a step further by asking Copilot to create a workflow file for us. This will set up CI/CD (Continuous Integration and Delivery) to Azure, with testing and deployment tracking built in — making our deployments smoother and more reliable. In the chat window, type or copy in: `Write a GitHub Actions workflow to deploy my python app to Azure, include testing for CI/CD`
148+
149+
Copilot provided the following workflow, review and accept the changes (or prompt Copilot to remediate if needed):
150+
151+
```YAML
152+
name: Python Flask CI/CD
153+
154+
on:
155+
push:
156+
branches: [ "main" ]
157+
pull_request:
158+
branches: [ "main" ]
159+
workflow_dispatch:
160+
161+
env:
162+
AZURE_WEBAPP_NAME: flaskapp
163+
PYTHON_VERSION: '3.10'
164+
165+
jobs:
166+
test:
167+
runs-on: ubuntu-latest
168+
steps:
169+
- uses: actions/checkout@v3
170+
171+
- name: Set up Python
172+
uses: actions/setup-python@v4
173+
with:
174+
python-version: ${{ env.PYTHON_VERSION }}
175+
176+
- name: Install dependencies
177+
run: |
178+
python -m pip install --upgrade pip
179+
pip install -r requirements.txt
180+
pip install pytest pytest-cov
181+
182+
- name: Run tests with pytest
183+
run: |
184+
pytest --cov=./ --cov-report=xml
185+
186+
- name: Upload coverage reports to Codecov
187+
uses: codecov/codecov-action@v3
188+
with:
189+
file: ./coverage.xml
190+
flags: unittests
191+
192+
build-and-deploy:
193+
needs: test
194+
runs-on: ubuntu-latest
195+
environment:
196+
name: 'Production'
197+
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
198+
199+
steps:
200+
- uses: actions/checkout@v3
201+
202+
- name: Set up Python
203+
uses: actions/setup-python@v4
204+
with:
205+
python-version: ${{ env.PYTHON_VERSION }}
206+
207+
- name: Install dependencies
208+
run: |
209+
python -m pip install --upgrade pip
210+
pip install -r requirements.txt
211+
212+
- name: Log in to Azure
213+
uses: azure/login@v1
214+
with:
215+
creds: ${{ secrets.AZURE_CREDENTIALS }}
216+
217+
- name: Deploy to Azure Web App
218+
id: deploy-to-webapp
219+
uses: azure/webapps-deploy@v2
220+
with:
221+
app-name: ${{ env.AZURE_WEBAPP_NAME }}
222+
package: .
223+
```
224+
225+
This workflow file includes the following capabilities:
226+
227+
- Testing job: Runs on every push and pull request to main branch, sets up Python 3.10, installs dependencies and testing tools, runs pytest with coverage reporting, uploads coverage reports to Codecov
228+
229+
- Build and Deploy job: Only runs after tests pass, sets up Python environment, installs dependencies, logs into Azure using credentials, deploys to Azure Web App
230+
231+
4. There is a multitude of tasks that you can complete with Copilot. Here are some sample ideas below:
232+
233+
- Connect a database to your app using PostgreSQL
234+
- add a user sign-in to your Python web app
235+
- Run your Python app in a container
236+
- Add monitoring by enabling Application Insights
237+
- Secure secrets by storing connecting strings in Azure Key Vault
238+
- Query Azure to perform a cloud cost optimization, find and remove unused resources in your subscription, or query Copilot for estimated costs of provisioned resources
239+
- Ask Copilot to run through security best practices for the applications' Azure setup
240+
- Create an architecture diagram from the deployment
241+
242+
🚀Congratulations! You’ve just leveled up by using GitHub Copilot with Azure MCP to code, deploy, and manage cloud resources — all without leaving your IDE
243+
244+
In the above exercises we achieved the following:
245+
- ✅ Enabling Azure MCP Server
246+
- ✅ Using Agent Mode to clearly define tasks
247+
- ✅ Creating a CI/CD workflow, including tests
248+
- ✅ Reviewing advanced use cases for using GitHub Copilot Chat with the Azure MCP Server
249+
250+
[Check out the other learning pathways in this repository.](### Useful Links and Further Learning)
251+
252+
253+
### Useful Links and Further Learning
254+
102255
- [Blog: Introducing GitHub Copilot for Azure: Your Cloud Coding Companion in VS Code!](https://techcommunity.microsoft.com/t5/microsoft-developer-community/introducing-github-copilot-for-azure-your-cloud-coding-companion/ba-p/4127644)
103256
- [Blog: GitHub Copilot for Azure: 6 Must-Try Features](https://techcommunity.microsoft.com/t5/microsoft-developer-community/github-copilot-for-azure-6-must-try-features/ba-p/4283126)
104257
- [Video: GitHub Copilot for Azure: 6 Must-Try Features](https://youtube.com/playlist?list=PLlrxD0HtieHgdwrN6ooxApdfBKTJK7465&si=9rl-kNItvFPeqhwa)
105258
- [Video: Build intelligent apps with Visual Studio Code, GitHub, and Azure](https://youtu.be/30OpmbWL1t8?si=FvkRqa-wxTHaU3qA&t=1024)
259+
260+
## Legal Notices
261+
262+
Microsoft and any contributors grant you a license to the Microsoft documentation and other content
263+
in this repository under the [Creative Commons Attribution 4.0 International Public License](https://creativecommons.org/licenses/by/4.0/legalcode),
264+
see the [LICENSE](LICENSE) file, and grant you a license to any code in the repository under the [MIT License](https://opensource.org/licenses/MIT), see the
265+
[LICENSE-CODE](LICENSE-CODE) file.
266+
267+
Microsoft, Windows, Microsoft Azure and/or other Microsoft products and services referenced in the documentation
268+
may be either trademarks or registered trademarks of Microsoft in the United States and/or other countries.
269+
The licenses for this project do not grant you rights to use any Microsoft names, logos, or trademarks.
270+
Microsoft's general trademark guidelines can be found at http://go.microsoft.com/fwlink/?LinkID=254653.
271+
272+
Privacy information can be found at https://privacy.microsoft.com/en-us/
273+
274+
Microsoft and any contributors reserve all other rights, whether under their respective copyrights, patents,
275+
or trademarks, whether by implication, estoppel or otherwise.
408 KB
Loading

0 commit comments

Comments
 (0)