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.
You must have already built a track to which you can add access to an Azure subscription.
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.
🌐 Web UI
💻 Instruqt CLI
- 1.
- 2.Click the TRACK_NAME of the track where you want to add Azure subscription access. ↳ Instruqt shows the corresponding Track overview page.
- 3.Click Track details followed by Sandbox to open the Sandbox page.
- 4.Click Add container +. ↳ The Create container page opens.
- 5.Enter/select these values:FieldValueName
cloud-client
Imagegcr.io/instruqt/cloud-client
Ports80
Shell/bin/bash
- 6.Click Save to add the container. ↳ On the Sandbox page, you will see the new container.
- 1.Open the file
config.yml
in your code editor. - 2.Copy and paste the following code under the
containers
property:- name: cloud-clientimage: gcr.io/instruqt/cloud-clientports: [80]shell: /bin/bash
🌐 Web UI
💻 Instruqt CLI
- 1.Click Add Azure subscription + on the Sandbox page. ↳ The Create Azure subscription page opens.
- 2.In the Name field, enter
azuresubscription
.Assigned rolesNote 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.Click Save to add the Azure subscription. ↳ On the Sandbox page, you will see the new Azure subscription.
- 4.Click Back to return to the Track overview page.
- 1.Copy and paste the following code into
config.yml
:azure_subscriptions:- name: azuresubscription↳ Yourconfig.yml
file should be similar to this now:version: "3"containers:- name: cloud-clientimage: gcr.io/instruqt/cloud-clientports: [80]shell: /bin/bashazure_subscriptions:- name: azuresubscriptionAssigned rolesNote theroles
property underazure_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.
🌐 Web UI
💻 Instruqt CLI
- 1.Click Add Challenge on the Track overview page. ↳ The New challenge page opens.
- 2.Enter/select these values:FieldValueTitle
Azure subscription
Slugazure-subscription
Assignment > Editor tabMarkdown text of your likingTeaserLearn to work with an Azure subscription
- 3.Click Save to add the challenge. ↳ On the Track overview page, you will see the new challenge.
- 4.Click Edit on the new challenge.
- 5.Click Tabs followed by New tab. ↳ The New tab page opens.
- 6.Enter/select these values to set the Azure portal:FieldValueTitle
Azure Portal
TypeService
Hostcloud-client
Path/
Port80
- 7.Click Save to add the tab.
- 8.Click New tab again.
- 9.Enter/select these values to set the
gcloud
CLI:FieldValueTitleaz CLI
TypeTerminal
Hostcloud-client
- 10.Click Save to add the tab. ↳ On the Challenge tabs page, you will see the new tabs.
- 11.Click Back followed by Build track.
- 12.Click Start track and test your Azure subscription.
- 1.Open a terminal and move to your track directory.
- 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.Open the
assignment.md
file in your code editor. - 4.Copy and paste the following code into
assignment.md
to set the Azure portal andaz
CLI:---slug: azure-challengetype: challengetitle: Azure subscriptionteaser: Learn to work with an Azure subscriptiontabs:- title: Azure Portaltype: servicehostname: cloud-clientpath: /port: 80- title: az CLItype: terminalhostname: cloud-clientdifficulty: basictimelimit: 600---⇨ You can add the assignment text of your liking in Markdown after line 17. - 5.Save file
assignment.md
. - 6.Push the track to the Instruqt platform:instruqt track push
- 7.Play and test the track:instruqt track open↳ Your browser opens, showing the Track overview page. Click Start track to play the track.
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 |
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.
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:
Last modified 8mo ago