Create an OSConfig (with Azure IoT) lab environment in 5 minutes

This article and associated sample script are for anyone who wants to quickly try out OSConfig scenarios, including multi-device scenarios. The script results in:

  • An Azure resource group (for organizing lab resources and easy cleanup)
  • An IoT Hub
  • One or many Azure VMs (as stand-ins for real IoT/Edge devices), which
    • Have OSConfig installed and running
    • Are connected to IoT Hub

If you are looking for background information on how, where, and why to install OSConfig, see: How and where to install the OSConfig agent for Linux.

After following this procedure, you will have a lab environment for trying out specific scenarios, such as managing network adapters, host names, package managers, custom configuration, and more.

Note

Given the ephemeral lab nature of this environment, each virtual device connects to IoT Hub using a simple connection string passed via command line. For a production deployment use stronger authentication and device identity mechanisms supported by Azure IoT, such as TPM or X.509 based identities.

Prerequisites

For an overall sense of pre-requisites, see the following screen capture. For detailed instructions, continue reading.

Screen capture showing launch of cloud shell and ensuring Azure IoT extension is installed

  1. An Azure account
  2. Azure Cloud Shell (recommended) or another bash environment with Azure CLI present and signed in to your Azure account
    • Cloud Shell enables easy access and sign-in via web browser, and provides a bash environment with Azure CLI already installed and authenticated
      • If this is your first time using Cloud Shell, the experience will include creating a storage account for your shell resources
    • If you prefer to use your own bash environment instead, ensure Azure CLI is installed and signed in to your account
    • You can use az account show to check that Azure CLI is signed into the account you want to use
  3. The Azure IoT extension for Azure CLI
    • You can ensure this is installed by running: az extension add --name azure-iot

Create your lab environment

For detailed instructions, select your preferred approach:

For an overall sense of the procedure, see the following screen capture. For detailed instructions, continue reading.

Screen capturing showing the download, modify, and run steps

  1. To download the script, use the command:

    curl -L https://aka.ms/OSConfigLabCreateExampleScript | tr -d '\r' > ./create-lab-fleet.sh
    
  2. Inspect and customize the script using your preferred text editor

    To use the nano text editor, for example, use the command:

    nano ./create-lab-fleet.sh
    

    Tip

    The first three parameters in the script are the most often customized:

    • Which Azure region to use (line 4 use_this_azure_location)
    • How many virtual IoT devices to create (line 5 create_this_many_devices)
    • Whether to use stable or preview builds of OSConfig (line 6 package_channels)
  3. Execute

    Once you are satisfied with your script (modified from the original sample), you can execute it by running the following:

    chmod +x ./create-lab-fleet.sh
    ./create-lab-fleet.sh
    

Next Steps

Now that you have a lab environment you can try out different OSConfig scenarios, for example:

Important

When you are ready to dispose of this lab environment you can run the following (replacing <RG_NAME> with the name of your resource group): az group delete --name <RG_NAME>. While these resources (VMs, IoT Hub, etc.) continue to exist they will consume some amount of your Azure credits or budget.