Links

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.

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. 1.
    Add an Instruqt Cloud Client container to your track.
  2. 2.
    Add an Azure subscription to your track.
  3. 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

🌐 Web UI
💻 Instruqt CLI
  1. 1.
    Open your browser and go to play.instruqt.com. ↳ Instruqt shows your content.
  2. 2.
    Click the TRACK_NAME of the track where you want to add Azure subscription access. ↳ Instruqt shows the corresponding Track overview page.
  3. 3.
    Click Track details followed by Sandbox to open the Sandbox page.
  4. 4.
    Click Add container +. ↳ The Create container page opens.
  5. 5.
    Enter/select these values:
    Field
    Value
    Name
    cloud-client
    Image
    gcr.io/instruqt/cloud-client
    Ports
    80
    Shell
    /bin/bash
  6. 6.
    Click Save to add the container. ↳ On the Sandbox page, you will see the new container.
  1. 1.
    Open the file config.yml in your code editor.
  2. 2.
    Copy and paste the following code under the containers property:
    - name: cloud-client
    image: gcr.io/instruqt/cloud-client
    ports: [80]
    shell: /bin/bash

Step 2: Add an Azure subscription to your track

🌐 Web UI
💻 Instruqt CLI
  1. 1.
    Click Add Azure subscription + on the Sandbox page. ↳ The Create Azure subscription page opens.
  2. 2.
    In the Name field, enter azuresubscription.
    Assigned roles
    Note the Assigned roles field where you can grant different access levels for your learners in the Azure subscription. Read the Azure built-in roles section to learn more about how to enable the right roles for your learners.
  3. 3.
    Click Save to add the Azure subscription. ↳ On the Sandbox page, you will see the new Azure subscription.
  4. 4.
    Click Back to return to the Track overview page.
  1. 1.
    Copy and paste the following code into config.yml:
    azure_subscriptions:
    - name: azuresubscription
    ↳ Your config.yml file should be similar to this now:
    version: "3"
    containers:
    - name: cloud-client
    image: gcr.io/instruqt/cloud-client
    ports: [80]
    shell: /bin/bash
    azure_subscriptions:
    - name: azuresubscription
    Assigned roles
    Note the roles property under azure_subscriptions where you can grant different access levels for your learners in the Azure subscription. Read the Azure built-in roles section to learn more about how to enable the right roles for your learners.

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

🌐 Web UI
💻 Instruqt CLI
  1. 1.
    Click Add Challenge on the Track overview page. ↳ The New challenge page opens.
  2. 2.
    Enter/select these values:
    Field
    Value
    Title
    Azure subscription
    Slug
    azure-subscription
    Assignment > Editor tab
    Markdown text of your liking
    Teaser
    Learn to work with an Azure subscription
  3. 3.
    Click Save to add the challenge. ↳ On the Track overview page, you will see the new challenge.
  4. 4.
    Click Edit on the new challenge.
  5. 5.
    Click Tabs followed by New tab. ↳ The New tab page opens.
  6. 6.
    Enter/select these values to set the Azure portal:
    Field
    Value
    Title
    Azure Portal
    Type
    Service
    Host
    cloud-client
    Path
    /
    Port
    80
  7. 7.
    Click Save to add the tab.
  8. 8.
    Click New tab again.
  9. 9.
    Enter/select these values to set the gcloud CLI:
    Field
    Value
    Title
    az CLI
    Type
    Terminal
    Host
    cloud-client
  10. 10.
    Click Save to add the tab. ↳ On the Challenge tabs page, you will see the new tabs.
  11. 11.
    Click Back followed by Build track.
  12. 12.
    Click Start track and test your Azure subscription.
  1. 1.
    Open a terminal and move to your track directory.
  2. 2.
    Enter the following command to create a new challenge:
    instruqt challenge create --title "AzureSubscription"
    ↳ Instruqt CLI created a directory for the challenge. And an assignment.md file inside the challenge directory.
  3. 3.
    Open the assignment.md file in your code editor.
  4. 4.
    Copy and paste the following code into assignment.md to set the Azure portal and az CLI:
    ---
    slug: azure-challenge
    type: challenge
    title: Azure subscription
    teaser: Learn to work with an Azure subscription
    tabs:
    - title: Azure Portal
    type: service
    hostname: cloud-client
    path: /
    port: 80
    - title: az CLI
    type: terminal
    hostname: cloud-client
    difficulty: basic
    timelimit: 600
    ---
    ⇨ You can add the assignment text of your liking in Markdown after line 17.
  5. 5.
    Save file assignment.md.
  6. 6.
    Push the track to the Instruqt platform:
    instruqt track push
  7. 7.
    Play and test the track:
    instruqt track open
    ↳ Your browser opens, showing the Track overview page. Click Start track to play the track.

Using 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. 1.
    Start your Azure subscription track and start the first challenge.
  2. 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:
🌐 Web UI
💻 Instruqt CLI
Update your Azure subscription by entering the following in the Assigned Roles field:
Virtual Machine Contributor
And clicking Add.
Edit your config.yml file to include this content:
azure_subscriptions:
- name: azuresubscription
roles:
- Virtual Machine Contributor
Great! Your learners can now access Azure subscriptions. But there is more. You can also give them access to: