Chapter 12: AI in DevOps engineering
This chapter introduces a practical-first approach to incorporating AI into existing DevOps workflows before covering GenAIOps fundamentals.
After this chapter you will be able to
- Natural-language command interfaces. Explain how AI can wrap DevOps commands and advanced processes in a natural-language interface that translates a user's request into the appropriate technical commands.
- Specialized coding assistants. Describe how coding assistants, including GitHub Copilot, Cline, and API Assistants, can be specialized with documentation and detailed prompts to support a team's codebase and standards.
- Pester v4-to-v5 migration challenge. Describe why upgrading the dbatools test suite from Pester v4 to Pester v5 was a major task. State that nearly 7,000 tests needed changes to syntax, scope rules, and assertion formats, making a manual update impractical.
- AI-assisted migration approach. Explain that the team used Aider and Cline together with PowerShell automation to undertake the delayed Pester migration. Identify Aider and Cline as tools previously covered in chapter 11.
- Aider project capabilities. Describe Aider as a command-line AI coding assistant that works directly with Git and understands the entire codebase, and explain the development tasks it can perform from natural-language or voice requests.
- Cline IDE complement. Explain why the team added Cline alongside Aider: Aider's command-line interface was useful but limited, whereas Cline provided additional development and testing features through Visual Studio Code integration.
- Iterative prompt refinement. Describe the step-by-step process of testing an AI conversion prompt on a single file, learning from its output, and applying improvements to subsequent files before increasing batch size.
- Single-file batch control. Explain why the team initially processed one test file at a time rather than five files together, and state when larger batches became feasible.
- Example-driven prompting. Explain why supplying actual tests from the codebase improved conversion success more than instructions alone, and describe the conventions demonstrated by those examples.
- Staged migration strategy. Describe why the team used a careful, organized implementation strategy rather than processing hundreds of files at once. Explain that the work was split into key areas so problems could be found early while progress continued at a steady pace.
- Focused passes for large files. Explain why large test files were converted through separate, single-task passes rather than updated all at once. State that files over 7.5 KB made AI models less accurate with complex instructions, while focused steps improved precision.
- Focused update passes. Describe the process of splitting a main test-upgrade prompt into separate, single-purpose passes, and explain why this lets the AI make one clear change at a time rather than manage many requirements at once.
- AI test-update outcomes. Describe the reported results of the AI-assisted test-update project, including its two-week completion and the concrete quality improvements made to the tests.
- Consistency and maintainability value. Explain why applying consistent standards across thousands of tests makes the suite easier to maintain and update, especially for the volunteer-supported open source dbatools project.
- Task-specific model selection. Explain that different AI models were effective for different kinds of code-update work: larger models such as Sonnet handled complex full-file changes best, while GPT-4o mini handled specific changes well.
- Large-scale refactoring viability. Describe the project's conclusion that AI can turn previously daunting large-scale code updates into organized, affordable work with a clear process and expected results.
- Context-aware code changes. Explain how Aider’s work on the Pester migration went beyond text replacement by understanding code context, test structure, and logic to make appropriate changes.
- GenAIOps management rationale. Justify the need for GenAIOps as teams add AI tools by stating that it provides an organized way to manage AI applications throughout their lifecycle using familiar DevOps methods.
- GenAIOps framework purpose. Explain why AI applications need specialized lifecycle management beyond standard DevOps and describe GenAIOps as a complete approach for managing generative AI applications.
- Iterative GenAIOps lifecycle phases. Trace the ideation, build, and operationalization phases of the GenAIOps lifecycle, including their activities, validation checkpoints, and the ability to return to earlier phases when results are inadequate.
- Retail Copilot workshop purpose. Describe how the Build a Retail Copilot workshop introduces GenAIOps through a practical customer-service chatbot implementation without requiring deep machine-learning knowledge.
- AI application core components. Explain the three essential parts illustrated by the workshop: a system for storing and finding relevant information, an AI model that understands user questions, and standard DevOps tooling for monitoring and maintenance.
What it builds on
- Key principles in prompt construction (chapter 4) · The idea that clear prompts and context help an AI produce useful outputs.
- GitHub AI suite (chapter 11) · GitHub's AI suite as a code-assistance tool.
- Cline (chapter 11) · Cline as a code assistant.
- Context injection (chapter 4) · Context injection for supplying relevant information to an AI.
- AI + dbatools = <3 (chapter 10) · The dbatools context introduced for advanced database administration.
- Aider (chapter 11) · The prior introduction to Aider as a code assistant.
- Learning from success (chapter 4) · Learning from successful prompt outcomes to improve later prompts.
- Recursive prompting (chapter 5) · Recursive prompting as an iterative way to improve results.
Section by section
Introduction
This chapter introduces a practical-first approach to incorporating AI into existing DevOps workflows before covering GenAIOps fundamentals.
- Practical-first DevOps AI approach: Explain why the chapter begins with practical AI additions to existing DevOps work rather than focusing first on GenAIOps. State that GenAIOps means managing AI applications using DevOps principles.
Why it matters: Starting with current DevOps tasks makes AI adoption concrete before moving to lifecycle practices for AI applications. - Chapter DevOps AI roadmap: Describe the AI-in-DevOps areas the chapter will cover: integrating AI into workflows, bulk PowerShell test conversion, tool and model selection, cost management, GenAIOps fundamentals, and AI-powered testing solutions.
Why it matters: The roadmap connects the practical project work with the broader concerns of selecting, operating, and testing with AI. - Experience-based chapter perspective: State that the chapter uses real examples, including AI for infrastructure automation and test-suite updates, and shares what worked, what problems occurred, and lessons learned.
Why it matters: The chapter's examples are intended to show both the benefits and the practical difficulties of applying AI in DevOps.
Key terms: GenAIOps, DevOps principles, AI applications, PowerShell tests, bulk code changes, AI-powered testing solutions, infrastructure automation, test suites, lessons learned
12.1 Practical AI use cases in DevOps
This section introduces three practical ways DevOps engineers can add AI to their workflow: natural-language command interfaces, specialized coding assistants, and task automation.
- Natural-language command interfaces: Explain how AI can wrap DevOps commands and advanced processes in a natural-language interface that translates a user's request into the appropriate technical commands.
Why it matters: This lets engineers make complex operational tasks easier to request without requiring users to remember exact command syntax. - Specialized coding assistants: Describe how coding assistants, including GitHub Copilot, Cline, and API Assistants, can be specialized with documentation and detailed prompts to support a team's codebase and standards.
Why it matters: A specialized assistant can help a team produce more reliable code that follows its own naming rules and best practices. - AI task automation: State how AI-driven task automation can support DevOps work involving documentation, dependencies, and maintenance, including complex upgrade projects.
Why it matters: Automation can reduce the manual effort involved in recurring engineering work and large maintenance initiatives.
Key terms: AI interfaces, natural language, PowerShell, kubectl, cloud CLI, Copy-DbaDatabase, coding assistants, GitHub Copilot, Cline, API Assistants
12.2 Upgrading nearly 7,000 tests: A real-world AI project
This section introduces the large-scale dbatools migration from Pester v4 to v5 and the AI-assisted approach used to make it feasible.
- Pester v4-to-v5 migration challenge: Describe why upgrading the dbatools test suite from Pester v4 to Pester v5 was a major task. State that nearly 7,000 tests needed changes to syntax, scope rules, and assertion formats, making a manual update impractical.
Why it matters: This explains the real operational problem that motivated the AI-assisted DevOps project. - AI-assisted migration approach: Explain that the team used Aider and Cline together with PowerShell automation to undertake the delayed Pester migration. Identify Aider and Cline as tools previously covered in chapter 11.
Why it matters: The project shows how AI coding tools and automation can make a previously deferred DevOps task tractable.
Key terms: Pester, Pester v4, Pester v5, dbatools, syntax, scope rules, Aider, Cline, PowerShell automation, AI-assisted development
12.2.1 Choosing our tools
This subsection explains why the project combined Aider and Cline, while noting how to recover from an occasional Aider Git-update problem.
- Aider project capabilities: Describe Aider as a command-line AI coding assistant that works directly with Git and understands the entire codebase, and explain the development tasks it can perform from natural-language or voice requests.
Why it matters: Aider provided the project with codebase-aware AI assistance and automatic Git-based change tracking. - Cline IDE complement: Explain why the team added Cline alongside Aider: Aider's command-line interface was useful but limited, whereas Cline provided additional development and testing features through Visual Studio Code integration.
Why it matters: Combining complementary tools let the team retain Aider's Git-oriented workflow while gaining capabilities inside its existing IDE. - Aider update recovery: Describe the occasional Git-related downside of Aider: an update can replace new code with old versions, and the stated recovery is to discard the affected changes and try again.
Why it matters: Recognizing this failure mode gives the team a simple recovery action instead of retaining reverted code.
Key terms: Aider, command-line AI coding assistant, Git, natural language, voice commands, descriptive message, Cline, Visual Studio Code integration, IDE, development features
12.2.2 Developing an effective process
This section develops an iterative, example-driven process for reliably using AI to convert Pester v4 tests to Pester v5.
- Iterative prompt refinement: Describe the step-by-step process of testing an AI conversion prompt on a single file, learning from its output, and applying improvements to subsequent files before increasing batch size.
Why it matters: An iterative process turns unreliable first attempts into a prompt that can produce consistent results at scale. - Single-file batch control: Explain why the team initially processed one test file at a time rather than five files together, and state when larger batches became feasible.
Why it matters: Controlling batch size prevents the AI from losing details or reversing earlier changes during a code migration. - Explicit Pester conversion rules: State the specific Pester v5 conversion instructions that made the prompt more concrete, including the module requirement, BeforeAll setup, assertion update, Context nesting, and preservation of test logic.
Why it matters: Concrete migration rules give the AI the technical guidance that a generic request to convert tests lacks. - Example-driven prompting: Explain why supplying actual tests from the codebase improved conversion success more than instructions alone, and describe the conventions demonstrated by those examples.
Why it matters: Concrete examples show the AI the desired code organization and local conventions rather than leaving it to infer them from abstract rules. - Conventions document limits: Describe the role of the conventions.md file and explain why its nearly 1,400-token instruction set required larger AI models.
Why it matters: The size of project guidance affects which AI models can reliably receive and use it.
Key terms: step-by-step process, batch, prompt, one file at a time, quality consistency, Pester v4, Pester v5, #Requires -Module Pester v5, BeforeAll, Assert-True
12.2.3 Implementation strategy
This section explains the staged implementation strategy used to update thousands of tests while maintaining quality and momentum.
- Staged migration strategy: Describe why the team used a careful, organized implementation strategy rather than processing hundreds of files at once. Explain that the work was split into key areas so problems could be found early while progress continued at a steady pace.
Why it matters: A staged approach makes a large AI-assisted code migration easier to control without sacrificing speed or quality. - Large-file strategy adjustment: State that the initial organized approach required adjustment when the team began working with larger files.
Why it matters: Recognizing when an approach no longer fits the size of the input is essential for adapting an AI-assisted workflow.
Key terms: implementation strategy, migration strategies, key areas, larger files, adjust our strategy
12.2.4 Managing large files
This section explains how splitting large test-file conversions into focused AI passes improved accuracy while keeping costs low.
- Focused passes for large files: Explain why large test files were converted through separate, single-task passes rather than updated all at once. State that files over 7.5 KB made AI models less accurate with complex instructions, while focused steps improved precision.
Why it matters: Breaking a complex conversion into smaller passes can make AI-assisted changes more reliable. - Conversion pass cost profile: State the approximate number of GPT-4o mini passes and cost used for each file: about nine passes at around 3 cents per file. Relate these figures to the approach being both effective and cost-efficient.
Why it matters: The example shows that a multi-pass workflow can be affordable rather than requiring a costly single large request.
Key terms: large files, separate steps, one task, passes, complex instructions, GPT-4o mini, nine passes, 3 cents per file, cost-efficient
12.2.5 Breaking down instructions into focused passes
This section explains how breaking a large AI code-update prompt into focused passes and reusing cached context improves accuracy, speed, and cost at scale.
- Focused update passes: Describe the process of splitting a main test-upgrade prompt into separate, single-purpose passes, and explain why this lets the AI make one clear change at a time rather than manage many requirements at once.
Why it matters: Focused passes make large AI-assisted code changes more manageable and reduce the burden of asking one prompt to perform every transformation at once. - Prompt caching at scale: Explain how prompt caching reuses saved context for similar files, including its short cache lifetime, its cost trade-off, and how Cline and Aider differ in enabling it.
Why it matters: Caching avoids repeatedly paying and waiting to send the same context when processing related files in a large project.
Key terms: focused passes, main prompt, single clear goal, BeforeAll, Pester v5, Context blocks, prompt caching, cache write, cache read, Cline
12.2.6 The results
This section reports that AI-assisted test updates finished quickly and improved consistency, clarity, and maintainability across the dbatools test suite.
- AI test-update outcomes: Describe the reported results of the AI-assisted test-update project, including its two-week completion and the concrete quality improvements made to the tests.
Why it matters: The outcome shows that AI can improve a large test suite rather than merely make superficial syntax changes. - Consistency and maintainability value: Explain why applying consistent standards across thousands of tests makes the suite easier to maintain and update, especially for the volunteer-supported open source dbatools project.
Why it matters: Consistent, clear tests reduce the effort required to maintain a large codebase with limited contributor time.
Key terms: Context block names, test names, PowerShell best practices, parameter handling, splatting, consistent standards, maintain, update, open source, dbatools
12.2.7 Lessons learned
Distills the model-selection and project-management lessons from using AI to update thousands of tests.
- Task-specific model selection: Explain that different AI models were effective for different kinds of code-update work: larger models such as Sonnet handled complex full-file changes best, while GPT-4o mini handled specific changes well.
Why it matters: Matching the model to the scope of the change can improve both the quality and cost of an AI-assisted update. - Cost-effective targeted updates: State that GPT-4o mini performed surprisingly well for specific changes and cost about $0.007 per file, making targeted AI updates inexpensive.
Why it matters: A low per-file cost can make a large batch of narrowly scoped code changes financially practical. - Large-scale refactoring viability: Describe the project's conclusion that AI can turn previously daunting large-scale code updates into organized, affordable work with a clear process and expected results.
Why it matters: This reframes large refactoring from work to avoid into work that can be planned and executed systematically.
Key terms: Sonnet, GPT-4o mini, full-file changes, specific changes, $0.007 per file, large-scale code updates, large refactoring, organized, affordable, clear process
12.2.8 Beyond test updates: Other uses for AI-assisted development
This subsection generalizes the Pester migration as evidence that context-aware AI-assisted development can handle large code changes and motivates GenAIOps for managing AI tools and applications.
- Context-aware code changes: Explain how Aider’s work on the Pester migration went beyond text replacement by understanding code context, test structure, and logic to make appropriate changes.
Why it matters: This shows why AI-assisted development can be useful for complex changes that require understanding how code fits together. - Pester migration change types: Describe the concrete kinds of changes AI made in the Pester migration: moving setup code into proper blocks, updating assertion syntax, and maintaining PowerShell best practices.
Why it matters: These examples make the claim of context-aware code modification concrete and observable. - GenAIOps management rationale: Justify the need for GenAIOps as teams add AI tools by stating that it provides an organized way to manage AI applications throughout their lifecycle using familiar DevOps methods.
Why it matters: A successful AI coding project still needs a disciplined approach for managing AI work as it grows across a team.
Key terms: Aider, Pester migration, code context, test structure, logic, setup code, proper blocks, assertion syntax, PowerShell best practices, GenAIOps
12.3 The GenAIOps lifecycle
This section introduces GenAIOps as an iterative lifecycle for taking generative AI applications from an idea through building and into monitored operation.
- GenAIOps framework purpose: Explain why AI applications need specialized lifecycle management beyond standard DevOps and describe GenAIOps as a complete approach for managing generative AI applications.
Why it matters: GenAIOps gives DevOps engineers a framework for managing AI-specific concerns as an application moves toward production. - AI operations framework distinctions: Distinguish MLOps, LLMOps, and GenAIOps by stating that MLOps applies CI/CD-like practices to machine-learning workflows, LLMOps specializes in LLMs, and GenAIOps manages generative AI applications more completely.
Why it matters: Choosing the right operations framework helps a team match its practices to the kind of AI system it is managing. - Iterative GenAIOps lifecycle phases: Trace the ideation, build, and operationalization phases of the GenAIOps lifecycle, including their activities, validation checkpoints, and the ability to return to earlier phases when results are inadequate.
Why it matters: The lifecycle provides a practical path for testing and improving a generative AI solution before and after it reaches production.
Key terms: GenAIOps, DevOps, generative AI applications, AI workflows, MLOps, LLMOps, CI/CD, machine learning, LLMs, ideation
12.3.1 Applying GenAIOps: A practical workshop example
This subsection uses Microsoft’s Build a Retail Copilot workshop to show how familiar DevOps, database, and monitoring practices apply to managing AI applications.
- Retail Copilot workshop purpose: Describe how the Build a Retail Copilot workshop introduces GenAIOps through a practical customer-service chatbot implementation without requiring deep machine-learning knowledge.
Why it matters: A concrete workshop can make GenAIOps approachable by connecting it to work DevOps engineers already do. - AI application core components: Explain the three essential parts illustrated by the workshop: a system for storing and finding relevant information, an AI model that understands user questions, and standard DevOps tooling for monitoring and maintenance.
Why it matters: AI applications need reliable data retrieval and operational management as well as a model that can interpret requests. - Hands-on operational practice: Describe the recommended way to use the workshop materials: work through videos, code samples, and hands-on exercises, then adapt the examples to the reader’s own environment while practicing deployment, performance monitoring, scaling, and data-quality concerns.
Why it matters: Hands-on adaptation turns a demonstration into transferable skills for operating AI systems reliably.
Key terms: Build a Retail Copilot, GenAIOps, customer service chatbot, Azure OpenAI Services, relevant information, database, AI model, standard DevOps tools, monitoring, hands-on exercises
12.4 Prompts used to write this chapter
This section lists example prompts used while writing the chapter, covering code-update planning, DevOps practice, format conversion, and code examples.
- Chapter-writing prompt examples: Describe the range of prompts used to write the chapter: summarizing a step-by-step script with a larger script as context, comparing GenAIOps with MLOps and LLMOps, converting Markdown tables to AsciiDoc, and asking why example code is effective.
Why it matters: These examples show how prompts can support both technical work and the preparation of technical material. - Contextual script-summary request: Explain how the first prompt asks for complete summary bullet points for a step-by-step script while providing the larger script for context, beginning with a specified first-pass instruction to add the Pester v5 module requirement.
Why it matters: Supplying both the focused script and its wider context can help an AI produce a more grounded task summary.
Key terms: GenAIOps, MLOps, LLMOps, Markdown, AsciiDoc, summary bulletpoints, First pass, #Requires -Module Pester v5, Pester v5
12.5 Summary
This summary recaps how AI supports DevOps work through coding assistance, automation, economical large-scale changes, and the GenAIOps lifecycle.
Where this is used later
- Acquiring new skills with AI assistance (chapter 17) · The DevOps context of applying AI to practical engineering work.
- Function calling (chapter 13) · The next chapter builds on these DevOps basics when introducing AI-powered applications and function calling.
- Building a database copilot (chapter 13) · Building a database copilot requires connecting natural-language AI interactions with database information.
- The functions (chapter 13) · Function design depends on understanding how AI applications connect models with data and external capabilities.
- Security considerations for function calling (chapter 13) · Operationally managing AI-powered applications includes the security considerations discussed later.
- Implementing function calling (chapter 13) · Implementing function calling requires adapting AI application examples and code to a practical environment.
- Practical applications and security considerations (chapter 13) · Practical applications require the same attention to operational integration and reliability.
Concepts explained in this chapter
- GenAIOpsGenAIOps is the practice of applying DevOps principles to the development, deployment, monitoring, and maintenance of generative AI applications.
- conversational aiConversational AI is artificial intelligence that supports ongoing dialogue by interpreting user messages and generating context-aware responses.
- step-by-step processA step-by-step process is a procedure that performs a task through an ordered sequence of progressively focused stages.
- AI agentAn AI agent is software that can pursue tasks toward objectives by interpreting information and taking actions with limited direct human intervention.
- monitoringLogging is the recording of runtime events and diagnostic information produced by a software system.
- tool usageFunction calling is a language-model capability that enables a model to request invocation of defined software functions or external services by producing structured arguments.
- promptA prompt is an instruction or input supplied to an AI system to elicit a specified response or output.
- AiderAider is an open-source terminal-based AI coding assistant that helps developers modify and manage software projects through natural-language instructions.
- ClineCline is an AI coding assistant implemented as a Visual Studio Code extension that can edit files, execute commands, and inspect web pages.
- automationAutomation is the execution of tasks or processes by systems with reduced direct human effort.
- DevOpsDevOps is a set of practices that integrates software development and IT operations through collaboration, automation, continuous delivery, and shared responsibility.
- artificial intelligenceArtificial intelligence is the field of creating computational systems that perform tasks associated with human intelligence, such as perception, reasoning, language processing, and decision-making.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.
