AI Agents • • 7 min read

GitHub Copilot CLI with managed identity: hub & spoke on Azure

I run GitHub Copilot CLI on Azure Virtual Desktop with the VM's managed identity and MCP servers to deploy a hub & spoke network on Azure.

Last updated on

Luca Torresi in a GitHub Copilot T-shirt, a GitHub Copilot CLI terminal on Windows 11 AVD and Azure resources: agentic deployment
Table of Contents

I keep playing with AI and with my Azure Virtual Desktop workstation dedicated to agents. This time the star is GitHub Copilot CLI: what it is, what you can do with it and why, in my opinion, it’s a much more interesting solution than Claude Code or its OpenAI counterpart, Codex. The scenario comes from my day-to-day work: testing an infrastructure for a customer by replicating their context in Azure.

The video with the full demo is coming soon to my YouTube channel.

The goal of the demo

To keep it simple, I asked GitHub Copilot CLI to build a hub & spoke network in a dedicated resource group, first directly and then with Template Specs and Azure Verified Modules. I’m starting from the workstation of the previous episode, the one running Hermes Agent.

Step 1: the workstation’s managed identity

The VM wrkst-ai-lt-0 has a system-assigned managed identity: an identity that represents the resource itself.

Identity page of the VM wrkst-ai-lt-0 in the Azure portal with the system-assigned managed identity turned on
Figure 1: The workstation’s system-assigned managed identity, status On

Next I picked a test resource group, rg-test-ai-itn-01, and from Access control (IAM) I assigned the VM’s identity the Contributor role. Keep in mind that Contributor is one of the privileged roles, which is exactly why I limit it to a single test resource group. If least privilege is your thing, I also covered it in my post on PIM and just-in-time managed groups.

Review of the Contributor role assignment to the VM wrkst-ai-lt-0 on resource group rg-test-ai-itn-01
Figure 2: Permanent Contributor assignment to the VM’s managed identity, scoped to the resource group
ItemValue
IdentitySystem-assigned managed identity of VM wrkst-ai-lt-0
RoleContributor
ScopeResource group rg-test-ai-itn-01
Assignment typeActive, permanent
EnvironmentTest only

Step 2: GitHub Copilot CLI and the MCP servers

I sign in to the VM, open PowerShell and type copilot.

I can resume a previous session or start a new one. In the session I’ve configured several MCP servers: for this demo the most interesting ones are the Azure one and the Microsoft Learn one, but there’s also the GitHub one, which comes in handy later.

GitHub Copilot CLI listing the connected MCP servers and the question about accessible resource groups
Figure 3: Connected MCP servers in GitHub Copilot CLI and the first question, asked in Italian

First question: “which resource groups do you have access to?”. The answer is correct, but based on my user, since I hadn’t given any other instruction. So I ask it to use the machine’s managed identity and run the same search. It finds exactly the test resource group. All of this written in Italian, without even switching to English.

I didn’t enable autopilot (YOLO mode), so I approve the actions: I’d rather see what it’s doing than let it run wild.

Step 3: hub & spoke in a few prompts

The prompt is very short: using the managed identity, deploy a hub & spoke network in the resource group, made of one hub and two peered spokes, using only official Microsoft documentation.

The agent pulls documentation from Microsoft Learn, reasons out an addressing plan and runs the commands. All with the default model, Claude Sonnet 5, a fairly light one.

GitHub Copilot CLI output with the commands that create the hub and spoke VNets and their peerings
Figure 4: The commands the agent ran for hub and spokes, referencing Microsoft’s hub-spoke architecture

In the portal I find the hub with its peerings. It left things mostly at their defaults, yet the hub & spoke is there, built in a few prompts. To dig deeper: hub & spoke with Azure Virtual Network Manager.

Overview of the VNet vnet-hub-itn-01 in Italy North with two peerings
Figure 5: The hub VNet in Italy North with its two peerings to the spokes

Step 4: starting over with a DevOps mindset

Then I raised the bar: delete everything done so far and redeploy the solution using Template Specs and Azure Verified Modules. In practice, I’m asking it to think in DevOps terms.

This is where the GitHub MCP comes in, because Azure Verified Modules live on GitHub. The agent handles dependencies between resources (peerings first), deletes everything and redeploys, still using the VM’s managed identity.

The result: a Template Spec, the hub & spoke with working peerings and a convincing naming convention, while I told it next to nothing. Genuinely exciting.

Not everything is perfect

It used the default subnet and chose a generous address space: a /16 on the hub. For a large enterprise it might make sense, but in SMB contexts it’s hard to justify. That’s why AI output always has to be understood and checked.

The key point: with few instructions and a light model you can get very far, but you have to own the process and understand what the AI produced.

Why I like GitHub Copilot CLI

GitHub Copilot CLI is a command-line tool to work with GitHub Copilot in agent mode. I could have done the same in VS Code, but the CLI has two advantages: direct access and multi-session. A flow I like: do the chat and planning in Visual Studio Code, then, when you get to the agentic part, open that session in GitHub Copilot CLI, where all your MCP servers are already configured.

More scenarios

  • From meeting to solution: you leave a customer meeting, pull the Teams meeting transcript through MCP with Work IQ, and start working on the Azure solution, from the CLI or from VS Code.
  • Anything command line: I wanted to try llama.cpp with a Qwen model locally, but the container needed CUDA to use my NVIDIA card. GitHub Copilot CLI built the container for me on Docker Desktop.
  • Lab environments: picture the CLI working with your test Proxmox or VMware.
  • Monitoring agents: an agent running on a Linux VM that monitors logs and insights of your web apps. Microsoft already thought about it with Azure SRE Agent. Picture an agent with limited permissions guarding your backups and performance.

I’m always talking about test environments: I’m not telling you this belongs in production, and in my opinion that shouldn’t even cross your mind.

The bigger picture

Hermes Agent, GitHub Copilot CLI and Microsoft Scout: they’re the robot’s body, but the brain comes from GitHub Copilot, which acts as the router to the models. Scout is very similar to a Microsoft OpenClaw, with Microsoft’s security and privacy guarantees.

Key takeaways

  • A system-assigned managed identity on an AVD VM lets the agent work on Azure without user credentials.
  • Limit the scope: Contributor, yes, but only on a test resource group.
  • With the Azure, Microsoft Learn and GitHub MCP servers, GitHub Copilot CLI deployed a hub & spoke and then rebuilt it with Template Specs and Azure Verified Modules.
  • Always check the output: a /16 on the hub is hard to justify for an SMB.
  • VS Code for chat and planning, the CLI for multi-session agentic execution.

Watch the video and let’s talk

The video with the full demo is coming soon: you’ll find it on my YouTube page. To learn more about me, visit About. Want to use GitHub Copilot CLI in your Azure environment, or see things differently? Reach out on LinkedIn or through the contact form on Sessionize.

Luca Torresi

Written by

Luca Torresi Microsoft Azure MVP

Cloud Solution Architect and Microsoft Azure MVP: landing zones, networking, security and hybrid cloud from the field.