Page
1
Trevoir W illiam s A gentic A I for D evO ps Engineers EXPERT INSIGHT Agentic AI for DevOps Engineers Building autonomous CI/CD, infrastructure, and operations workfl ows Trevoir Williams THINGS YOU WILL LEARN • Build a practical foundation in Generative AI for DevOps • Apply AI across GitHub, Azure DevOps, and CI/CD workfl ows • Use AI to improve automation, infrastructure, and operational eff iciency • Implement AI with guardrails, governance, and enterprise awareness • Evaluate agentic AI for advanced DevOps scenarios • Understand how agentic AI, tools, memory, and MCP extend DevOps automation • Use AI to improve code, pipelines, infrastructure as code, and documentation Agentic AI for DevOps is a practical, hands-on guide to building autonomous DevOps workfl ows powered by AI agents, LLMs, and intelligent automation systems. The book shows you how to modernize software delivery and cloud operations by integrating AI into CI/CD pipelines, infrastructure automation, observability, incident response, and platform engineering. You’ll learn how to design AI-driven workfl ows that can analyze logs, automate deployments, optimize infrastructure, remediate failures, and improve operational eff iciency with minimal human intervention. Through real-world projects and demonstrations, the book explores the use of AI copilots, orchestration frameworks, cloud-native tooling, and DevOps platforms to create scalable and production-ready autonomous systems. The book also covers prompt engineering, AI workfl ow orchestration, security, governance, and best practices for building reliable AI-powered DevOps environments. By the end of the book, you’ll be able to confidently build, deploy, and manage AI-driven DevOps systems that improve speed, reliability, scalability, and operational eff iciency. www.packtpub.com Agentic AI for DevOps Engineers https://packtpub.com/unlock/9781808083570 Get a free PDF copy of this book
Page
2
Agentic AI for DevOps Engineers Building autonomous CI/CD, infrastructure, and operations workflows Trevoir Williams
Page
3
Agentic AI for DevOps Engineers Copyright © 2026 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. Portfolio Director: Kartikey Pandey Relationship Lead: Aaron Tanna Project Manager: Sonam Pandey Content Engineer: Sayali Pingale Technical Editor: Simran Ali Indexer: Tejal Soni Production Designer: Shantanu Zagade Growth Lead: Meghal Patel First published: July 2026 Production reference: 1270726 Published by Packt Publishing Ltd. Grosvenor House 11 St Paul's Square Birmingham B3 1RB, UK. ISBN 978-1-80808-357-0 www.packtpub.com
Page
4
To my wife and daughter, whose love, patience, and encouragement sustain me through every ambitious project. This book is also dedicated to every learner and engineer willing to grow, adapt, and build responsibly in a rapidly changing industry. – Trevoir Williams
Page
5
Contributors About the author Trevoir Williams is a Jamaican-born software and systems engineer, author, Microsoft Certified Trainer, and technical educator specializing in .NET, Azure, DevOps, cloud architecture, secure software development, and generative AI. He holds a master's degree in computer science with a focus on software development and multiple Microsoft Azure certifications. Trevoir has taught more than 500,000 learners through practical, project-driven courses. He is the author of Effective .NET Memory Management and Microservices Design Patterns in .NET (2 editions), and a contributor to Azure Integration Guide for Business. His work helps developers apply modern engineering practices to secure, production-ready systems.
Page
6
Table of Contents Preface xi Free benefits with your book ................................................................................................ xviii Chapter 1: Generative AI Concepts for DevOps 1 How generative AI helps DevOps engineers .............................................................................. 2 What is generative AI? • 2 What is an LLM? • 2 Automation in DevOps • 3 Mapping AI to real DevOps work ............................................................................................... 3 AI-assisted and AI-autonomous DevOps ................................................................................... 6 Risks associated with AI usage .................................................................................................. 7 Summary .................................................................................................................................. 9 Chapter 2: Practical Applications of Generative AI in DevOps 11 Technical requirements ............................................................................................................ 12 AI-assisted Infrastructure as Code (IaC) ................................................................................... 12 Demo: AI-assisted IaC (Bicep + GitHub Copilot) • 13 Step 1: Creating the first bicep template • 13 Step 2: Validating the first deployment • 16 Step 3: Extending the template in small increments • 17 Step 4: Adding the container app and securing image access • 21 Step 5: Creating a parameter file • 23 Reviewing AI-generated issues • 24 Authoring CI pipelines with AI assistance ............................................................................... 25 Demo: Pipeline authoring using AI • 25 Step 1: Creating the initial CI workflow • 26 Step 2: Validating the generated YAML • 27 Step 3: Improving and debugging the workflow • 28
Page
7
Supporting pull request validation with AI ............................................................................. 32 Demo: Creating the PR validation workflow • 33 Step 1: Creating the workflow • 33 Step 2: Adding stricter quality gates • 35 Step 3: Adding a deterministic PR summary • 36 Step 4: Testing the workflow in a pull request • 38 Generating structured release notes with AI ........................................................................... 39 Demo: Creating a GitHub actions workflow • 39 Step 1: Creating the release notes workflow • 39 Step 2: Generating markdown release notes from metadata • 41 Step 3: Validating and drafting the release • 41 Step 4: Debugging workflow permissions • 42 Step 5: Testing the workflow with a feature release • 44 Assisting incident triage with AI ............................................................................................. 45 Demo: Using AI to review failure reasons and suggest fixes • 46 Step 1: Creating a controlled failure • 46 Step 2: Explaining the failed workflow • 47 Step 3: Generating a structured incident note • 48 Summary ................................................................................................................................ 49 Chapter 3: DevOps AI Tools, Governance, and Enterprise Readiness 51 Understanding the DevOps AI tool landscape ......................................................................... 52 Reviewing the AI tools in the existing stack ............................................................................ 54 IDE-level AI • 54 Pull request AI • 55 Pipeline-level AI • 56 Cloud AI layer • 57 Establishing AI guardrails ....................................................................................................... 58 Auditing and accountability ................................................................................................... 60 Building an AI adoption playbook ........................................................................................... 61 Measuring the ROI of AI in DevOps ......................................................................................... 63 Summary ................................................................................................................................ 65 Chapter 4: Integrating Generative AI Into DevOps Pipelines 67 Technical requirements ........................................................................................................... 68 Table of Contents vi
Page
8
Provisioning an AI engine for pipeline integration .................................................................. 69 Choosing the AI engine • 69 Provisioning Azure OpenAI for the pipeline • 70 Designing deterministic AI workflow steps ............................................................................. 74 Step 1: Creating the new AI release workflow • 75 Step 2: Collecting pull request metadata • 76 Step 3: Generating release notes with AI • 78 Step 4: Validating the generated release notes • 80 Step 5: Publishing the draft release • 81 Step 6: Testing the workflow with a pull request • 81 Step 7: Reviewing the generated release • 82 Creating a reusable Azure OpenAI composite action ............................................................... 82 Step 1: Creating the composite action folder • 83 Step 2: Defining the action inputs • 83 Step 3: Defining the action outputs • 84 Step 4: Validating inputs and dependencies • 85 Step 5: Calling Azure OpenAI from the composite action • 86 Step 6: Updating the release workflow • 89 Step 7: Fixing the composite action path • 90 Reducing prompt and input complexity .................................................................................. 91 Step 1: Updating the PR metadata collection branch • 91 Step 2: Adding truncation and sanitization helpers • 91 Step 3: Updating the PR information fields • 92 Step 4: Remove unnecessary metadata fields • 92 Step 5: Adding API call guardrails • 93 Step 6: Strengthening the prompt instructions • 94 Step 7: Testing the updated workflow • 94 Managing AI costs and performance ....................................................................................... 95 Step 1: Skipping AI calls when there are no PRs • 96 Step 2: Adding retry and backoff logic • 96 Step 3: Handling success, failure, and retry attempts • 97 Step 4: Tracking token consumption • 98 Step 5: Creating the telemetry artifact • 98 Step 6: Adding conditions to validation and publishing jobs • 99 Step 7: Testing the full flow with a pull request • 100 vii Table of Contents
Page
9
Adding observability and feedback ........................................................................................ 101 Secure AI integration patterns in CI/CD ................................................................................ 106 Extending the workflow with AI-augmented ChatOps .......................................................... 110 Step 1: Creating the ChatOps workflow • 111 Step 2: Creating the ChatOps prompt • 114 Step 3: Creating the GitHub token • 114 Step 4: Updating the workflow with the token • 115 Step 5: Adding and testing the workflow • 116 Summary ............................................................................................................................... 119 Chapter 5: Agentic AI for CI/CD Failure Triage and PR Quality Assessment 121 Technical requirements .......................................................................................................... 122 What is an AI agent? ............................................................................................................... 123 Components of an agent • 123 Using agents safely in CI/CD pipelines .................................................................................. 124 Safe and unsafe CI/CD use cases • 124 Guardrails for DevOps agents • 125 Demo: Building a DevOps failure triage agent ........................................................................ 125 Implementing the file-based failure triage agent • 126 Setting up the CI workflow for triage • 131 Validating the failure triage workflow • 133 Why do agents fail in production? .......................................................................................... 135 Progressive autonomy ............................................................................................................ 136 Autonomy levels • 136 Promoting agents between levels • 138 Agentic patterns in DevOps workflows .................................................................................. 139 Demo: Building a PR quality assessment agent ..................................................................... 140 Demo: Integrating an agent into the PR analysis workflow .................................................... 147 Summary ............................................................................................................................... 153 Chapter 6: Agentic AI for Advanced DevOps Scenarios: Memory and MCP 155 Technical requirements .......................................................................................................... 156 Memory in DevOps agents ..................................................................................................... 157 Table of Contents viii
Page
10
What to store and what to avoid • 157 Production safeguards for durable memory • 158 Demo: Adding workflow-level memory to a DevOps agent .................................................... 159 Creating the memory-enabled ChatOps workflow • 160 Updating the ChatOps prompt for durable memory • 167 Configuring and testing the memory ledger • 168 Tools and MCP: Standardizing context and actions across agents .......................................... 171 Demo: building an MCP server for GitHub tooling ................................................................. 172 Architecture overview • 172 Creating the MCP server project • 173 Implementing the GitHub API client • 176 Defining the MCP tools • 178 Demo: Testing the MCP server with postman ....................................................................... 180 Connecting postman to the stdio MCP server • 181 Extending the pull request quality agent with MCP tools • 185 Demo: Testing and verifying the GitHub workflow with the MCP agent ................................ 187 Configuring the MCP-enabled PR analysis workflow • 188 Testing the MCP-integrated workflow • 190 Extension exercise • 192 Summary ............................................................................................................................... 193 Chapter 7: Multi-Agent Incident Response and Agent Observability 195 Technical requirements .......................................................................................................... 195 Why use multiple agents? ..................................................................................................... 196 When multi-agent orchestration is worth it • 197 Orchestration patterns • 197 Safety boundaries and guardrails • 197 Demo: Building a multi-agent incident response workflow .................................................. 199 Setting up sample incident data • 199 Writing the specialist prompts • 201 Implementing the orchestration workflow • 204 Demo: Running the multi-agent workflow ............................................................................ 212 Configure credentials and execute the workflow • 212 Observability and evaluation in AI agents ............................................................................. 214 Traces, logs, and metrics • 215 ix Table of Contents
Page
11
Monitoring versus evaluation • 215 Demo: Instrumenting an agent with OpenTelemetry ............................................................ 217 Add OpenTelemetry instrumentation and output evaluation • 217 Demo: Setting up aspire and testing observability ................................................................ 223 Summary .............................................................................................................................. 227 Chapter 8: Conclusion and Next Steps: Applying Generative AI to DevOps Responsibly 229 What this book established ................................................................................................... 230 Principles that remain constant ............................................................................................. 231 A production readiness checklist ............................................................................................ 231 Adopt autonomy progressively .............................................................................................. 232 Measure outcomes and improve continuously ...................................................................... 233 Next steps: Adopt AI incrementally and safely ....................................................................... 233 Continuing your learning ...................................................................................................... 234 Final takeaways ..................................................................................................................... 235 Chapter 9: Unlock Your Exclusive Benefits 237 Unlock this Book's Free Benefits in 3 Easy Steps .................................................................... 238 Other Books You May Enjoy 242 Index 245 Table of Contents x
Page
12
Preface Generative AI is evolving from experimental developer use to integration within systems that plan, build, test, release, operate, and monitor software. This shift offers meaningful opportunities: AI can cut down on repetitive tasks, help engineers understand complex data, and broaden access to expertise. However, it also introduces a new type of operational risk. An incorrect but plausible suggestion in a chat window may be inconvenient, but the same suggestion integrated into a CI/CD workflow could impact infrastructure, security, or live production environments. As a software and systems engineer, author, and technical educator working across .NET, Microsoft Azure, cloud architecture, DevOps, and AI-assisted development, I have seen that practitioners do not need more hype or isolated demonstrations. They need a practical path from experimentation to controlled implementation. This book was written to provide that path and to connect generative AI capabilities with the engineering disciplines that make production systems trustworthy. The book builds progressively. It begins with the concepts DevOps professionals need to evaluate generative AI, then applies AI to infrastructure as code, pipeline authoring, pull request validation, release communication, and incident triage. It then moves into enterprise governance and controlled pipeline integration before introducing narrowly scoped agents, durable memory, Model Context Protocol (MCP) tools, multi-agent incident response, evaluation, and observability. The reference implementation uses GitHub, GitHub Actions, GitHub Copilot, Azure OpenAI, .NET 10, C#, Microsoft Agent Framework, OpenTelemetry, and the Aspire Dashboard. These products provide a practical and cohesive stack, but the architectural lessons are transferable. The enduring concerns are controlled context, least-privilege access, structured outputs, deterministic validation, secure tool use, traceability, and accountable human decision-making. Throughout the book, the operating model is straightforward: let AI assist or propose, let deterministic automation validate and execute, and keep accountable engineers in control of consequential decisions. The objective is not to automate engineering judgment away. It is to reduce toil, improve visibility, and help teams deliver software with greater confidence.
Page
13
Who this book is for This book mainly targets DevOps engineers interested in integrating generative AI into delivery and operations while maintaining reliability and control. It also benefits software developers managing CI/CD workflows, platform and cloud engineers, site reliability engineers, incident responders, security engineers, solution and cloud architects, as well as technical leads and engineering managers considering AI adoption for their development teams. Readers should already understand the purpose of source control, pull requests, CI/CD, cloud infrastructure, and automated delivery. No previous experience building large language model applications or AI agents is required. This is a practitioner-focused book rather than an introduction to programming, Git, or DevOps fundamentals. What this book covers Chapter 1, Generative AI Concepts for DevOps, introduces generative AI and large language models, maps AI to the DevOps lifecycle, distinguishes AI assistance from AI autonomy, and examines hallucination, drift, and overreach. Chapter 2, Practical Applications of Generative AI in DevOps, uses a generate, validate, and monitor lifecycle to apply AI to Bicep infrastructure as code, CI pipeline authoring, pull request validation, release notes, and incident triage while keeping review and approval in human hands. Chapter 3, DevOps AI Tools, Governance, and Enterprise Readiness, zooms out from individual workflows to the enterprise AI tool landscape. It covers risk-based tool selection, guardrails, auditing, accountability, organizational adoption, and measuring return on investment. Chapter 4, Integrating Generative AI Into DevOps Pipelines, integrates Azure OpenAI with GitHub Actions, covers provisioning model access, secret management, reusable actions, structured and validated outputs, context engineering, cost, and performance controls, telemetry, secure integration patterns, and AI-augmented ChatOps. Chapter 5, Agentic AI for CI/CD Failure Triage and PR Quality Assessment, defines the anatomy of a DevOps agent and builds narrowly scoped .NET 10 agents for CI failure triage and pull request quality assessment. It also examines safe and unsafe CI/CD actions, schema validation, failure modes, and progressive autonomy. Chapter 6, Agentic AI for Advanced DevOps Scenarios: Memory and MCP, explains what DevOps agents should retain, implements a GitHub issue as a validated memory ledger, introduces MCP, builds and tests a C# MCP server, and connects an existing pull request agent and GitHub Actions workflow to standardized tools. Preface xii
Page
14
Chapter 7, Multi-Agent Incident Response and Agent Observability, examines when multi-agent specialization is justified, compares orchestration patterns, builds a multi-agent incident response workflow, and adds evaluation and OpenTelemetry instrumentation that can be inspected in the standalone Aspire Dashboard. Chapter 8, Conclusion and Next Steps: Applying Generative AI to DevOps Responsibly, consolidates the book's operating principles into a production-readiness checklist, a progressive-autonomy model, measurable adoption criteria, and practical next steps for responsible implementation. To get the most out of this book To benefit fully from the exercises, you should understand Git repositories, branches, commits, pull requests, and the purpose of CI/CD pipelines. You should also be familiar with core DevOps practices, cloud resource concepts, identity and secret management, and the difference between development and production environments. The examples use YAML, JSON, Markdown prompt files, shell commands, Bicep, and C#. You do not need to be an expert in every format, but you should be comfortable reading structured configuration, using a terminal, and following step-by-step technical demonstrations. The labs are cumulative, so work through them in sequence and keep the repository under source control. Start from the provided baseline, inspect every AI-generated suggestion before accepting it, run the documented validation steps, and compare your result with the finished reference only after attempting the implementation yourself. C# is the primary programming language for the agent implementations. Prior C# and .NET experience is helpful, but readers familiar with another object-oriented language should be able to follow the architecture and adapt the patterns to another platform. Use synthetic or sanitized data for log, incident, pull request, and observability exercises. Technical requirements The exercises use hosted model APIs and do not require a local GPU. A current Windows, macOS, or Linux development machine with internet access is sufficient. The reference environment includes the following: .NET 10 SDK. The agent chapters use .NET 10 file-based C# applications and the dotnet run ‑‑file command. Git and a GitHub account with a repository that has GitHub Actions, Issues, and pull requests enabled. You need permission to create branches, workflow files, environments, repository variables, and secrets. Visual Studio Code with the C# Dev Kit extension. Visual Studio or JetBrains Rider can also be used for the C# exercises. • • • xiii Preface
Page
15
GitHub Copilot and Copilot Chat for the AI-assisted coding and infrastructure demonstrations in Chapter 2. An Azure subscription with access to Microsoft Foundry and Azure OpenAI, together with a deployed chat model and permission to retrieve its endpoint, key, and deployment name. Azure CLI and the Bicep CLI for the infrastructure-as-code exercises. The jq command-line utility for JSON validation. GitHub-hosted Ubuntu runners include jq, but local and self-hosted environments may require installation. Postman with MCP request support for testing the local stdio MCP server. Docker Desktop or another OCI-compatible container runtime for the standalone Aspire Dashboard exercise. Local ports 18888, 4317, and 4318 must be available. The examples use Azure OpenAI as the reference model provider, but the surrounding workflow patterns can be adapted to another managed or self-hosted model service. Some Azure SDK and Microsoft Agent Framework packages were prerelease versions when the demonstrations were prepared. Use the versions pinned in the book repository for reproducibility, or upgrade and retest the complete solution against current official release notes. Download the example code files The code bundle for the book is hosted on GitHub at https://github.com/PacktPublishing/ Agentic-AI-for-DevOps-Engineers. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing. Check them out! The project is organized around baseline and completed reference implementations. Use the start content when beginning a lab and the finish content for comparison and verification. Where a chapter points to a pinned commit, that reference preserves the exact implementation used while the book was prepared. Download the color images Your purchase includes a color, DRM-free PDF copy of this book, ideal for viewing color images, screenshots, and diagrams. Refer to Free benefits with your book section at the end of the Preface to unlock your PDF copy. • • • • • • Preface xiv
Page
16
Conventions used There are a number of text conventions used throughout this book. CodeInText: Indicates code words in text, environment variables, class and method names, filenames, extensions, paths, commands, and user input. For example: "Set AZURE_OPENAI_ENDPOINT before running DevOpsFailureTriageAgent.cs." A block of code is set as follows: var endpoint = Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT") ?? throw new InvalidOperationException("Set AZURE_OPENAI_ENDPOINT."); Any command-line input or output is written as follows: dotnet run --file ai/agents/DevOpsFailureTriageAgent.cs Bold: Indicates a new term, an important word, or words that you see on the screen. For example: "Select Settings, then Secrets and variables, and then Actions." Warnings or important notes appear like this. Note Tips and practical recommendations appear like this Tip xv Preface
Page
17
Stay ahead in AI-Powered networking – join 16,000+ subscribers AI is changing how networks are designed, managed, automated, and secured. The AI Networking newsletter delivers focused, practical insights to help networking professionals keep pace with this shift. Each issue explores topics such as: AI-assisted network automation and troubleshooting Agentic workflows for network operations MCP, network copilots, and emerging AI tools Guardrails for safe and reliable automation Real-world approaches to building AI-ready networks Whether you're a network engineer, infrastructure professional, automation specialist, or technology leader, AI Networking helps you understand what is changing (and how to apply it) without the noise. Scan the QR code to join for free and get weekly insights straight to your inbox: https://theainetworkengineer.substack.com/ • • • • • Preface xvi
Page
18
Get in touch Feedback from our readers is always welcome. General feedback: If you have questions about any aspect of this book or have any general feedback, please email us at customercare@packt.com and mention the book's title in the subject of your message. Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you reported this to us. Please visit https://www.packt.com/submit-errata, click Submit Errata, and fill in the form. Piracy: If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at copyright@packt.com with a link to the material. If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit https:// authors.packt.com/. Share your thoughts Once you've read Agentic AI for DevOps Engineers, we'd love to hear your thoughts! Scan the QR code below to go straight to the Amazon review page for this book and share your feedback. https://packt.link/r/1-808-08357-1 Your review is important to us and the tech community and will help us make sure we're delivering excellent quality content. xvii Preface
Page
19
Free benefits with your book This book comes with free benefits to support your learning. Activate them now for instant access (see the "How to Unlock" section for instructions). Here's a quick overview of what you can instantly unlock with your purchase: Preface xviii
Page
20
How to Unlock Scan the QR code (or go to packtpub.com/unlock). Search for this book by name, confirm the edition, and then follow the steps on the page. Note: Keep your invoice handy. Purchases made directly from Packt don't require one xix Preface