Azure subscriptions

Give learners access to Azure subscriptions.

This guide explains how to access an Azure subscription from Instruqt.

An Azure subscription is a logical container used to provision resources in Azure. It holds the details of all your resources like virtual machines (VMs), databases, and more. When you create an Azure resource like a VM, you identify the subscription it belongs to.

ā€” Azure documentation

Before you begin

You must have already built a track to which you can add access to an Azure subscription.

Access Azure subscriptions

It is best to add the Instruqt Cloud Client container to your track to give a learner access to an Azure subscription. Because the Instruqt Cloud Client:

  • Exposes links to the Azure portal for the resources configured in the config.yml file, with the credentials required to log in.

  • Includes the az CLI, pre-configured with the required credentials.

The Azure portal and the az CLI make it easy for content developers and learners to access Azure subscription resources from the sandbox.

It takes the following steps to give learners access to an Azure subscription:

  1. Add an Instruqt Cloud Client container to your track.

  2. Add an Azure subscription to your track.

  3. Add tabs to your challenges where you want to expose the Azure portal or az CLI.

Additionally, you can use:

  • A set of environment variables that are available in the az CLI.

  • Azure built-in roles.

Step 1: Add an Instruqt Cloud Client container to your track

  1. Click the track where you want to add an Azure subscription to.

  2. In the Sandbox section, click Edit to open the Sandbox page.

  3. Click + Add a host. ā†³ The Add host page opens.

  4. Pick the Container host type.

  5. Enter/select these values:

    FieldValue

    Hostname

    cloud-client

    Image type

    Choose your own

    Image

    gcr.io/instruqt/cloud-client

  6. Click Show optional settings. Enter these values:

    FieldValue

    Ports

    80

    Shell

    /bin/bash

  7. Click Save host to add the container.

Step 2: Add an Azure subscription to your track

  1. Click + Add a cloud account on the Sandbox page.

  2. Select the Azure provider.

  3. In the Name field, enter azuresubscription.

  4. Click Save to add the Azure subscription. ā†³ On the Sandbox page, you will see the new Azure subscription.

  5. Click Back to track to return to the Track dashboard page.

Only provide access to services that are strictly needed to prevent abuse. See Access role for more details.

Step 3: Add tabs to expose the Azure portal and az CLI

  1. In the Challenges section of the Track dashboard, click Add new followed by Assignment.

  2. Enter/select these values:

    FieldValue

    Tab name

    Azure subscription

    URL

    azure-subscription

    Description

    Learn about Azure

  3. Click Save.

  4. Click Tabs followed by Add new tab.

  5. Select the Your applications tab type.

  6. Enter/select these values to set the Azure portal:

    FieldValue

    Tab name

    Azure Portal

    Select your host

    cloud-client

    Path

    /

    Port

    80

  7. Click Save to add the tab.

  8. Click Add new tab again.

  9. Select the Terminal tab type.

  10. Enter/select these values to set the gcloud CLI:

    FieldValue

    Tab name

    az CLI

    Host

    cloud-client

  11. Click Save to add the tab.

  12. Click the track name to return to the Track dashboard.

  13. Click Play track and test your Azure subscription.

Environment variables

Adding an Azure subscription to your track also sets a list of environment variables that you can use in commands and scripts:

Environment variable

Description

INSTRUQT_AZURE_SUBSCRIPTIONS

A comma-separated list of project names that can be used to fill ${NAME} in the variables below

INSTRUQT_AZURE_SUBSCRIPTION_${NAME}_SUBSCRIPTION_NAME

The subscription display name

INSTRUQT_AZURE_SUBSCRIPTION_${NAME}_SUBSCRIPTION_ID

The subscription ID

INSTRUQT_AZURE_SUBSCRIPTION_${NAME}_USERNAME

The username that can be used to sign into the Azure portal

INSTRUQT_AZURE_SUBSCRIPTION_${NAME}_PASSWORD

The password that can be used to sign into the Azure portal

INSTRUQT_AZURE_SUBSCRIPTION_${NAME}_SPN_ID

The application ID for the service principal

INSTRUQT_AZURE_SUBSCRIPTION_${NAME}_SPN_PASSWORD

The password for the service principal

INSTRUQT_AZURE_SUBSCRIPTION_${NAME}_TENANT_ID

The tenant ID for this subscription

Example

This example shows the id of the Azure subscription from a terminal by using two environment variables. The value of the INSTRUQT_AZURE_SUBSCRIPTIONS environment variable is inserted in the INSTRUQT_AZURE_SUBSCRIPTION_${NAME}_SUBSCRIPTION_ID environment variable.

To follow along:

  1. Start your Azure subscription track and start the first challenge.

  2. Move over to the Cloud CLI terminal and enter the following command:

    eval echo "\${INSTRUQT_AZURE_SUBSCRIPTION_${INSTRUQT_AZURE_SUBSCRIPTIONS}_SUBSCRIPTION_ID}"

    ā†³ The terminal shows the id of your Azure subscription.

Azure built-in roles

The roles option allows you to choose one or more Azure built-in roles to grant access to your Azure subscription. See Azure built-in roles that you can apply.

You might start with the role Virtual Machine Contributor which gives the learner the ability to spin up and configure Azure virtual machines:

Update your Azure subscription by entering the following in the Assigned Roles field:

Virtual Machine Contributor

And clicking Add.

Great! Your learners can now access Azure subscriptions. But there is more. You can also give them access to:

Last updated