Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Learn Azure Administration - Second Edition

You're reading from  Learn Azure Administration - Second Edition

Product type Book
Published in Dec 2023
Publisher Packt
ISBN-13 9781837636112
Pages 346 pages
Edition 2nd Edition
Languages
Author (1):
Kamil Mrzygłód Kamil Mrzygłód
Profile icon Kamil Mrzygłód

Table of Contents (23) Chapters

Preface 1. Part 1:Introduction to Azure for Azure Administrators
2. Chapter 1: Azure Fundamentals 3. Chapter 2: Basics of Infrastructure as Code 4. Part 2: Networking for Azure Administrator
5. Chapter 3: Understanding Azure Virtual Networks 6. Chapter 4: Exploring Azure Load Balancer 7. Part 3: Administration of Azure Virtual Machines
8. Chapter 5: Provisioning Azure Virtual Machines 9. Chapter 6: Configuring Virtual Machine Extensions 10. Chapter 7: Configuring Backups 11. Chapter 8: Configuring and Managing Disks 12. Part 4: Azure Storage for Administrators
13. Chapter 9: Configuring Blob Storage 14. Chapter 10: Azure Files and Azure File Sync 15. Chapter 11: Azure Storage Security and Additional Tooling 16. Part 5: Governance and Monitoring
17. Chapter 12: Using Azure Policy 18. Chapter 13: Azure Monitor and Alerts 19. Chapter 14: Azure Log Analytics 20. Chapter 15: Exploring Network Watcher 21. Index 22. Other Books You May Enjoy

Configuring Virtual Machine Extensions

After learning about Azure Virtual Machines, it’s time to see how one can extend their capabilities by installing additional extensions and plugins. In Azure, you can quite easily add a service or a component to any deployed instances of Azure Virtual Machines – the only requirement is to do so according to the platform’s requirements.

Basic knowledge of setting up and configuring extensions for Azure Virtual Machines will come in handy when deploying additional components used, for example, for monitoring or auditing your infrastructure.

In this chapter, we’re going to cover the following main topics:

  • How to use virtual machine extensions
  • How to implement a Custom Script Extension
  • What is the Desired State Configuration (DSC)?

Technical requirements

For the exercises from this chapter, you’ll need the following:

The Code in Action video for this book can be viewed at: https://packt.link/GTX9F

Using virtual machine extensions

Once your virtual machine is deployed, it’s ready to be used and configured. In many scenarios, you don’t need to do anything besides installing some basic software needed by your services. However, there are use cases where you need a certain functionality for your virtual machine – this can be implemented in various ways, but very often, the easiest path is by using an extension.

Azure offers a couple of predefined extensions available for most virtual machines. However, availability depends on a couple of factors:

  • Region
  • Operating system
  • Additional capabilities of the virtual machine

The easiest way to learn what is available for your setup is to run the following command in the Azure CLI:

az vm extension image list --location <location> --output table

This command will return a list of available extensions per given location. It’ll also include additional information, such as the name...

Implementing the Custom Script Extension

One of the most useful extensions is the Custom Script Extension. This extension allows you to run scripts on your virtual machines to provide custom logic or install additional software. Often, this extension is used to complete the configuration of your machine when it isn’t possible to use the standard deployment options.

Important note

Use of the Custom Script Extension shouldn’t replace tools such as Ansible, Chef, or Puppet when configuring a machine. If you need to configure a large number of machines or require advanced control tools, the Custom Script Extension will become cumbersome and difficult to maintain.

Let’s see how to use this extension for basic scenarios.

Installing software with the Custom Script Extension

To get started, we’ll need to create an Azure Virtual Machine that we will then configure later using the extension. Use the following commands to deploy an empty Linux machine...

What is the Desired State Configuration?

There are two possible definitions for Desired State Configuration (DSC) in the context of Azure:

  • An extension for PowerShell used for bootstrapping and managing Azure Virtual Machines
  • A general concept where you work toward developing an automated solution for configuration management of your infrastructure

In this section, we’ll focus on both definitions for a better understanding of the whole concept.

Azure Automation State Configuration

In Azure, you can automatically manage the desired state of your virtual machines by leveraging Azure Automation State Configuration. This feature is basically a configuration file that you create and pass to your infrastructure. Your infrastructure will handle the passed configuration via an installed DSC agent and apply all the changes defined in it.

Such a configuration looks something like the following:

configuration IISInstall
{
    node "...

Summary

As we’ve seen in this chapter, extensions for Azure Virtual Machines can be used to automate a selection of management activities and operations (e.g., backups or monitoring) and to help initialize a machine with additional services and applications. One of the most useful extensions is the Custom Script Extension, which allows you to run any logic contained within a script you provide. It’s a powerful feature, though do note that it’s not meant for setting up configuration at a large scale.

Remember that extensions in Azure Virtual Machines can be used for a wide variety of use cases, starting with installing monitoring agents or Configuration-as-Code agents (such as Puppet). What’s more, they’re generally pretty straightforward features to set up, meaning that you don’t need to provision additional infrastructure to get them working.

In the next chapter, we’ll focus on configuring and using backups for virtual machines...

lock icon The rest of the chapter is locked
You have been reading a chapter from
Learn Azure Administration - Second Edition
Published in: Dec 2023 Publisher: Packt ISBN-13: 9781837636112
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}