Running Azure CLI

The final step is to add environment variables in our course in order to store user credentials and log into Azure CLI.

Terminal

Since our main means of interaction with AWS is the CLI, we can use the Terminal widget to achieve this interface.

Try running az login in the Terminal below:

Terminal 1
Terminal
Loading...

However, with this approach, users will have to log in each time since every Terminal session is independent.

We can avoid this redundancy by using environment variables.

Environment Variables

In the Docker Container section of the course editor page, clicking the globe icon allows you to add environment variables in your course:

These variables will be available in any coding playground/terminal present in the course.

Let’s create two environment variables, username and password.

We can leave the Value field empty since these values need to be provided by the user.

To save an environment variable, always click on the Save icon next to it.

Selecting Env Vars in the Terminal

Now, you can select which environment variables are required in a Terminal widget:

We’ve selected both variables in our Terminal. To use the values provided by a user, we will add the following command in the Start Script of our Terminal:

az login -u $username -p $password

The $ notation is used to access environment variables. We simply have to pass these values as arguments in the az login command.

Azure CLI in Action

With all our configurations in place, it’s time to run the container. Enter your Azure credentials below and launch the Terminal.

Terminal 1
Terminal
Loading...

Users can now work with whatever services they have on their Azure accounts.


That marks the end of this tutorial! We’ve examined the basic setup required to run Azure on the Educative platform. Feel free to make additions to the Dockerfile according to your needs.