Azure Intro

12th Mar 2024

You will learn:

  • Login
  • Work with Azure Portal
  • Working with Azure CLI
  • Deploying a Python Flask application without a container

Access "Azure Dev Tools for Teaching"

To create an account, you must use the Azure for Students page..

Tap the green "Start Free" button.

Then on "Sign In"

After the Sign In prompt - you log in similarly to MAIS, enter your login before ad.tuke.sk:

 ad.tuke.sk\ab123cd
 PASSWORD

The system will require you to enter a phone number to send a verification SMS.

After some time and verification of your phone number, you will log in to the Azure Portal.

Check the Azure CLI

Run the WSL2 Ubuntu command line. Install the latest version of Azure CLI (Python 3 dependency).

Azure line client should be installed in your environment

 az

Creating a connection to the cloud

Create a connection with your account on the Azure cloud. Login and authentication will take place using a web browser:

 az login

If for some reason a graphical web browser does not work, use

 az login --use-device-code

Then open a web browser and enter the displayed device code.

You connect az to the Azure cloud.

Working with Azure CLI

Azure CLI can replace the web interface. Although the command line is less intuitive at first glance, we can mark the procedure of the web application deployment commands into files, archive, share and repeat.

There are quite a few options for interacting with Azure.

After the basic az command there is another command that has additional subcommands and arguments.

For example

 az resources list

lists the currently deployed resources. The output will be in JSON format. This format is easy to parse, e.g. in Python, or using the jq utility.

Using the `--help' switch, you can display help for each command.

Familiarize yourself with Azure Web App Services

Before using the cloud service, you should familiarize yourself with it.

https://azure.microsoft.com/en-us/products/app-service/web/

Azure Web App services can facilitate the process of deploying code to an Azure production environment, the process of managing and scaling applications without directly having to deal with building a Docker container image. Internally, however, the container image will be compiled and deployed to the cloud.

Prepare the files

Create a directory with the web application and place the app.py file from exercise no. 4:

 mkdir cv5
 cd cv5
 wget https://student.kemt.fei.tuke.sk/zkt/cvicenia/azureintro/app.py
 echo flask > requirements.txt

The requirements.txt file contains a list of Python packages required by the application. Everything necessary will be installed accordingly.

Creating App Service webapp

See the help for the `webapp up' command first

 az webapp up --help

Choose a name for your application. The name must be unique, because it determines the DNS name for your server. Next, you need to select the resource group name, SKU, and data center location. You can read the possible SKU and location from the help.

 az webapp up --sku B1 --name cv6webapp --resource-group myapp --location westeurope

It will take some time to deploy the application.

If everything went well, your application will appear at the URL assigned to it by Azure.

Open your browser and see if it works.

Cancel the application

So that she does not spend credit.

az group delete --no-wait --resource-group myapp

Materials

Previous Post Next Post

Azure Intro