Chapter 7. Creating RHEL system image and uploading to Microsoft Azure using Red Hat Image Builder

You can create customized RHEL system images using Red Hat Image Builder, and upload those images to the Microsoft Azure cloud target environment. Then, you can create a Virtual Machine (VM) from the image you shared with the Microsoft Azure Cloud account.

7.1. Authorizing Red Hat Image Builder to push images to Microsoft Azure Cloud

Authorize Red Hat Image Builder to push images to the Microsoft Azure cloud. For that, you must:

  • Configure Red Hat Image Builder as an authorized application for your tenant GUID
  • Give it the role of Contributor to at least one resource group.

    To authorize Red Hat Image Builder as an authorized application, follow the steps:

Prerequisites

  • You have an existing Resource Group in Microsoft Azure portal.
  • You have the User Access Administrator role rights.
  • Your Microsoft Azure subscription has Microsoft.Storage and Microsoft.Compute as a resource provider.

Procedure

  1. Access Red Hat Image Builder on a browser.

    The Red Hat Image Builder dashboard appears.

  2. Click Create image.

    The Create image dialog wizard opens.

  3. On the Image output page, complete the following steps:

    1. From the Release list, select the Release that you want to use: for example, choose Red Hat Enterprise Linux (RHEL).
    2. From the Select target environments option, select Microsoft Azure.

      Click Next.

  4. On the Target Environment - Microsoft Azure window, to add Red Hat Image Builder as an authorized application, complete the following steps:

    1. Insert your Tenant GUID.

      Image Builder checks f your Tenant GUID is correctly formatted and the Authorize Image Builder button becomes available.

    2. Click Authorize Image Builder to authorize Red Hat Image Builder to push images to the Microsoft Azure cloud.

      This redirects you to the Microsoft Azure portal.

      1. Login with your credentials.
      2. Click Accept the Permission requested.
    3. Confirm that Red Hat Image Builder is authorized for your tenant.

      1. Search for Azure Active Directory and choose Enterprise applications, from the left menu.
      2. Search for Red Hat Image Builder and confirm it is authorized.
    4. Add the Enterprise application as a contributor to your Resource Group.

      1. In the search bar, type Resource Groups and select the first entry under Services. This redirects you to the Resource Groups dashboard.
      2. Select your Resource Group.
      3. On the left menu, click Access control (IAM) to add a permission so the Red Hat Image Builder application can access your resource group.
      4. From the menu, click the tab Role assignments.
      5. Click +Add.
      6. From the dropdown menu, choose Add role assignment. A menu appears on the left side.
      7. Insert the following details:

        1. Role: Assign the Contributor role
        2. Assign access to: User, group, service principal. Add members: Click +Select members and type Red Hat in the search bar. Press enter.
        3. Select: Red Hat Image Builder application

The Red Hat Image Builder application is now authorized to push images to Microsoft Azure cloud.

Note

Even though any user can add an application to the resources group, the application is not able to locate any resource unless the account administrator adds the shared application as a contributor under the IAM section of the resource group. .

Verification

  • From the menu, click the tab Role assignments.

    You can see Red Hat Image Builder set as a Contributor of the Resource Group you selected.

7.2. Creating a customized RHEL system image for Microsoft Azure using Image Builder

After you authorize Image Builder to push images to Microsoft Azure, create customized system images using Image Builder and upload those images to Microsoft Azure. For that, follow the steps:

Prerequisites

Procedure

  1. On the Target Environment - Microsoft Azure window, complete the following steps:

    1. Enter your Tenant GUID: you can find your Tenant ID in the Azure Active Directory application in Microsoft Azure Portal.
    2. Enter your Subscription ID: you can find your Subscription ID account by accessing the Microsoft Azure console.
    3. Enter your Resource group: is the name of your Resource Group in Microsoft Azure Portal.

      Click Next.

  2. On the Registration page, select the type of registration that you want to use. You can select from these options:

  3. Optional: On the Packages page, add packages to your image. See Chapter 4, Adding packages during image creation by Using Red Hat Image Builder.
  4. On the Name image page, enter a name for your image and click Next. If you do not enter a name, you can find the image you created by its UUID.
  5. On the Review page, review the details about the image creation and click Create image.

    After you complete the steps in the Create image wizard, the Image Builder dashboard is displayed.

    Red Hat Image Builder starts the compose of a RHEL Azure Disk Image image for the x86_64 architecture, uploads it to the resource group account you specified, and creates an Azure Image.

    The Red Hat Image Builder Images dashboard opens. You can see details such as the Image UUID, the cloud target environment, the image OS release and the status of the image creation. After the status is Ready, the Azure Disk Image is shared with the specified account.

    On the dashboard, you can see details such as the Image UUID, the cloud target environment, the image OS release and the status of the image creation.

    Possible statuses:

    • Pending: the image upload and cloud registration is being processed.
    • In Progress: the image upload and cloud registration is ongoing.
    • Ready: the image upload and cloud registration is completed
    • Failed: the image upload and cloud registration failed.

      Note

      The image build, upload and cloud registration processes can take up to ten minutes to complete.

Verification

  • Check if the image status is Ready. It means that the image upload and cloud registration completed successfully.

7.3. Accessing your customized RHEL system image from your Microsoft Azure account

After you have build and uploaded the image, and the cloud registration process status is marked as Ready, you can access the Azure Disk Image from your Microsoft Azure account.

Prerequisites

Procedure

  • Access your Microsoft Azure dashboard and navigate to the Resource group page.

Verification

  1. After you access your Microsoft Azure Account, you can see that the image successfully shared with the resource group account you specified.

    Note

    If the image is not visible there, you may have issues with the upload process. Return to the Red Hat Image Builder dashboard and check if the image is marked as Ready.

7.4. Creating a VM from the RHEL system image shared with the Azure account

You can create a Virtual Machine (VM) from the image you shared with the Microsoft Azure Cloud account by using Red Hat Image Builder.

Prerequisites

Procedure

  1. Click + Create VM. You are redirected to the Create a virtual machine dashboard.
  2. In the Basic tab under Project Details, your Subscription and the Resource Group are pre-set.

    Optional: If you want to create a new resource Group:

    1. Click Create new.

      A pop-up prompts you to create the Resource Group Name container.

    2. Insert a name and click OK.

      If you want to keep the Resource Group that is already pre-set.

  3. Under Instance Details, insert:

    1. Virtual machine name
    2. Region
    3. Image
    4. Size: Choose a VM size that better suits your needs.

      Keep the remaining fields as in the default choice.

  4. Under Administrator account, enter the following details:

    1. Username: the name of the account administrator.
    2. SSH public key source: from the drop-down menu, select Generate new key pair.
    3. Key pair name: insert a name for the key pair.
  5. Under Inbound port rules:

    1. Public inbound ports: select Allow selected ports.
    2. Select inbound ports: Use the default set SSH (22).
  6. Click Review + Create. You are redirected to the Review + create tab. You receive a confirmation that the validation passed.
  7. Review the details and click Create.

    To change options, click Previous.

  8. A Generates New Key Pair pop-up opens. Click Download private key and create resources.

    Save the key file in the yourKey.pem file format.

  9. After the deployment is complete, click Go to resource.

    You are redirected to a new window with your VM details.

  10. Select the public IP address on the top right side of the page and copy it to your clipboard.

Verification

Create an SSH connection to connect to the Virtual Machine you created. For that, follow the steps:

  1. Open a terminal.
  2. At your prompt, open an SSH connection to your virtual machine. Replace the IP address with the one from your VM, and replace the path to the .pem file with the path to where the key file was downloaded.

    # ssh -i <yourKey.pem file location> <username>@<IP_address>
    • Add the user name and replace the IP address with the one from your VM.
    • Replace the path to the .pem file with the path to where the key file was downloaded.

      For example:

      # ssh -i ./Downloads/yourKey.pem azureuser@10.111.12.123
  3. You are required to confirm if you want to continue to connect. Type yes to continue.

    As a result, the output image you shared with the Azure Storage account is started and ready to be provisioned.

    Note

    The default user is azureuser and the password is azureuser.