An AI-powered Azure infrastructure deployment tool that uses LangGraph workflows and Azure MCP (Model Context Protocol) to automate resource deployments.
This project sits on top of the LangChain ecosystem. LangChain provides the building blocks for LLM applications, such as prompts, models, tools, and structured output. It is useful when you want to connect an LLM to external systems and give it reusable components for reasoning and action.
LangGraph builds on that foundation and adds workflow orchestration. Instead of treating an agent as a single black-box call, LangGraph models the application as a graph with explicit control flow and durable state. That makes it a strong fit for multi-step processes like infrastructure generation, validation, approval, and deployment.
Key LangGraph concepts used in this project:
- State: A shared data object that carries information between steps, such as the user request, generated Bicep, validation results, and deployment status.
- Nodes: Individual workflow steps that perform work, such as parsing user input, generating code, building templates, or deploying resources.
- Edges: Connections between nodes that define what runs next. Edges can be linear or conditional.
- Conditional Routing: Logic that chooses the next step based on the current state, for example retrying code refinement when a Bicep build fails or pausing for human approval before deployment.
- Interrupts / Human-in-the-Loop: A workflow can pause and wait for a human decision, then resume from the same point with the updated input.
In this Azure Deployment Agent, LangChain handles the LLM-driven tasks and tool integration, while LangGraph manages the end-to-end deployment workflow as a reliable, inspectable graph.
- 🤖 Natural Language Processing: Describe your infrastructure needs in plain English
- 📝 Bicep Code Generation: Automatically generates Azure Bicep templates
- ✅ Validation Pipeline: Multi-stage validation including build and pre-deployment checks
- 👤 Human-in-the-Loop: Review and approve generated code before deployment
- 🚀 Automated Deployment: Deploys resources to Azure using Azure CLI
- 📊 Deployment Verification: Verifies deployment status and outputs results
- 🖥️ Multiple Interfaces: CLI and Gradio web UI
The agent uses a LangGraph workflow with the following stages:
- Parse User Input: Extracts deployment parameters from natural language
- Generate Infrastructure Code: Creates Bicep templates using Azure MCP tools
- Build Bicep: Validates Bicep syntax
- Refine Code (if needed): Fixes syntax errors using LLM
- Pre-validate: Validates deployment against Azure
- Human Review: Pause for approval
- Deploy: Executes deployment using Azure CLI
- Verify: Confirms deployment status
azure_deployment_agent/
├── core/ # Core components
│ ├── __init__.py # Core package exports
│ ├── models.py # Pydantic models and TypedDicts
│ ├── config.py # LLM and MCP configuration
│ └── utils.py # Helper functions (Azure CLI wrapper)
├── workflow/ # Workflow components
│ ├── __init__.py # Workflow package exports
│ ├── nodes.py # Workflow node functions
│ ├── edges.py # Conditional edge routing
│ └── graph.py # Graph construction and compilation
├── __init__.py # Package initialization
├── main.py # CLI entry point
├── gradio_app.py # Web UI application
├── requirements.txt # Python dependencies
├── .env.example # Environment variables template
└── README.md # This file
-
Clone or copy the
azure_deployment_agentfolder to your system -
Install dependencies:
pip install -r requirements.txt- Set up environment variables:
# Copy the example file
cp .env.example .env
# Edit .env with your Azure OpenAI credentials- Ensure Azure CLI is installed and you're logged in:
az login- Install Node.js (required for Azure MCP server):
# Azure MCP server runs via npxRun the agent from the command line:
python main.pyYou'll be prompted to enter a deployment request. Examples:
- "Create a storage account named mysa123 in rg-aidemo in East US with standard LRS"
- "Create a key vault named kv-demo-01 in rg-aidemo in West Europe with soft delete enabled"
- "Create an App Service Plan named asp-demo in rg-aidemo in East US with B1 tier"
View the workflow graph:
python main.py --graphLaunch the Gradio interface:
python gradio_app.pyThen open your browser to the URL shown (typically http://127.0.0.1:7860)
import asyncio
from azure_deployment_agent import create_deployment_graph, DeploymentAgentState
async def deploy():
app = create_deployment_graph()
initial_state = {
"user_input": "Create a storage account named mysa in rg-demo in East US"
}
config = {"configurable": {"thread_id": "my-session"}}
result = await app.ainvoke(initial_state, config)
# Handle human review if needed
if "__interrupt__" in result:
# ... approve/reject logic
pass
asyncio.run(deploy())Required:
AZURE_OPENAI_ENDPOINT: Your Azure OpenAI endpoint URLAZURE_OPENAI_KEY: Your Azure OpenAI API key
Optional (for Azure MCP authentication):
AZURE_CLIENT_ID: Service principal client IDAZURE_CLIENT_SECRET: Service principal client secretAZURE_TENANT_ID: Azure tenant IDAZURE_USE_MSI: Set to "true" for managed identity authentication
- Storage Accounts
- Key Vaults
- App Service Plans
- Application Insights
- Function Apps
- Update the
parsed_inputmodel in core/models.py with new fields - Update the parsing prompt in
parse_user_inputnode in workflow/nodes.py - Test with example requests
Modify workflow/graph.py to:
- Add new nodes
- Change routing logic
- Add additional validation steps
- Python 3.9+
- Azure CLI
- Node.js (for Azure MCP server)
- Azure subscription with appropriate permissions
- Azure OpenAI service
MIT License
Contributions are welcome! Please submit pull requests or open issues for bugs and feature requests.
- Ensure you're logged in:
az login - Check your subscription:
az account show - Verify permissions for resource group creation and deployments
- Ensure Node.js is installed
- Check that
npxis available in your PATH - Verify Azure credentials if using service principal authentication
- Check the generated Bicep code in the logs
- The agent will attempt to auto-fix common syntax errors
- Review Azure naming conventions and resource limits
For issues and questions, please open an issue in the repository or contact the maintainers.