diff --git a/content/Azure/01_intro_to_cloud_console.ipynb b/content/Azure/01_intro_to_cloud_console.ipynb index 144522e..1315d3b 100644 --- a/content/Azure/01_intro_to_cloud_console.ipynb +++ b/content/Azure/01_intro_to_cloud_console.ipynb @@ -2,10 +2,10 @@ "cells": [ { "cell_type": "markdown", - "id": "dc57021c", + "id": "dba7ad08", "metadata": {}, "source": [ - "# Introduction to the AWS Console\n", + "# Introduction to the Azure Console\n", "\n", "\n", "```{admonition} Overview\n", @@ -19,8 +19,8 @@ "* How do I navigate the web console?\n", "\n", "**Objectives:**\n", - "* Log in to the AWS web console\n", - "* Navigate the AWS web console\n", + "* Log in to the Azure web console\n", + "* Navigate the Azure web console\n", "* Recognize important information about your cloud environment\n", "\n", "```" @@ -28,18 +28,12 @@ }, { "cell_type": "markdown", - "id": "502f2360", - "metadata": {}, - "source": [] - }, - { - "cell_type": "markdown", - "id": "acf07f2b", + "id": "ed22965b", "metadata": {}, "source": [ "### Setup\n", "\n", - "The console is the point of entry where you will start your AWS journey. If you are participating in the CLASS Essentials Workshop, you will have received a csv file via email. This csv file contains your **username**, **temporary password** and **console login link**. \n", + "The console is the point of entry where you will start your Azure journey. If you are participating in the CLASS Essentials Workshop, you will have received a csv file via email. This csv file contains your **username**, **temporary password** and **console login link**. \n", "\n", "```{admonition} Be Aware\n", ":class: danger\n", @@ -47,54 +41,38 @@ "```\n", "\n", "### Logging in to the console\n", - "Paste your console login link into your web browser. You will see the AWS site requesting you to sign in as an IAM user. Fill in your username and password that was assigned to you in the csv file. You will be asked to change your password the first time you sign in to the console. Fill in your old password and then choose a new password that you can remember! \n", + "Paste your console login link into your web browser. You will see the Azure site requesting your username and password. Fill in your username and password that was assigned to you in the csv file. \n", "\n", "You are now logged on. Welcome to the first step of your cloud journey! \n", "\n", - "Figure 1 is what your screen should look like when you log in to the AWS console for the first time. If you encounter any pop up boxes, you can exit them. Next, let's take a closer look at some key concepts and components of the AWS console. \n", + "Figure 1 is what your screen should look like when you log in to the Azure console. Next, let's take a closer look at some key concepts and components of the Azure console. \n", "\n", - "\n", - "\n", - "
Figure 1: First time logging in to the AWS console

" - ] - }, - { - "cell_type": "markdown", - "id": "930220c5", - "metadata": {}, - "source": [ - "### Key concepts and components of the AWS console\n", - "\n", + "\n", "\n", - "
Figure 2: Basic but important components of the AWS Console

\n" + "
Figure 1: Logging in to the Azure console

" ] }, { "cell_type": "markdown", - "id": "22bf4b20", + "id": "15ee81a4", "metadata": {}, "source": [ - "Figure 2 lists the basic components you will see when you first log in to the AWS console. \n", - "\n", - "**1. Services**\n", - ": If you click on the dropdown menu labeled \"Services\" you will see the entire list of services that is offered by AWS. Currently, AWS has over 200 services ranging from compute to machine learning to networking to data storage. The list grows frequently!\n", + " **1. Hamburger**\n", + ": If you click on the hamburger (three horizontal lines) you will get a dropdown menu and see a list of services that are offered by Azure. Currently, Azure has over N services ranging from compute to machine learning to networking to data storage. The list grows frequently!\n", "\n", "**2. Search bar**\n", - ": You can also use the search bar to find a particular service or offering that you are interested in. Cloud vendors have proprietary vocabulary or jargon, so it is often useful to be aware of those as you start exploring more in your cloud adoption journey. [Internet2's CLASS Core documentation](https://github.internet2.edu/pages/CLASS/CLASS-Essentials-AWS/vendor_vocabulary.html) provides a basic list of vendor specific cloud terminology. For example, if you wanted to provision or utilize a \"virtual server\", you can try using the search bar to search for \"EC2\" which stands for \"Elastic Cloud Compute\" and is the AWS vocabulary for virtual computers.\n", + ": You can also use the search bar to find a particular service or offering that you are interested in. Cloud vendors have proprietary vocabulary or jargon, so it is often useful to be aware of those as you start exploring more in your cloud adoption journey. [Internet2's CLASS Core documentation](https://github.internet2.edu/pages/CLASS/CLASS-Essentials-AWS/vendor_vocabulary.html) provides a basic list of vendor specific cloud terminology. For example, if you wanted to provision or utilize a \"virtual server\", you can try using the search bar to search for \"Virtual Machines\". As you start typing the words starting with \"V\" will auto fill. Choose Virtual Machines from the options displayed.\n", "\n", - "**3. IAM Username and Account**\n", - ": The menu bar on the console also lists your IAM username and account number. IAM is short for Identity and Access Management. Identity is a mechanism to authenticate users (e.g. password) and Access is a mechanism for authorizing what kinds of services users have access to. For example, in this scenario, student1 is an IAM user on the account \"4414-3982-1395\". In the creation of the IAM user \"student1\", the administrator (overlord) of the account assigned a particular permission scope (in AWS this is known as roles) to ensure that student1 only has access to a particular set of services and also assigned a password to authenticate user login. IAM is a key component in managing security on the cloud.\n", + "**3. Cloud Shell**\n", + ": The cloud shell button invokes an interactive shell environment for either bash or PowerShell. The first time you invoke cloud shell you will also creare persistent storage specifically for cloud shell. The cloud shell comes with linux tools like bash, sh, & dig as well as the Azure CLI. Cloud shell also has editors like VIM and emacs, and tools like git, make, and configuration tools like ansible & terraform already installed. Language support for python, go, java, & PowerShell are also preinstalled. Azure Cloud Shell runs on Ubuntu 16.04 LTS with persistent storage.\n", "\n", - "**4. Region**\n", - ": AWS (and most cloud providers) uses the term region to denote the physical location of the data center(s) you are building your cloud service(s) in. Here we see that the region is \"Ohio\". This literally means that as you develop some of your AWS components like compute and storage, the physical location of your server and data is in the state of Ohio! Regions are important to know and understand for two major reasons: costs and latency. Transferring data between regions in AWS incurs what is known as a inter-region data fee (roughly $0.16/GB as of 2021). If you work with larger datasets, you may find that data transfer speeds (e.g. downloading, processing data, etc.) in different regions can occur more slowly due to something called latency. For the sake of optimizing costs and minimizing latency, you are encouraged to choose a region that is closest to you and your cloud data. For the CLASS Essentials Workshop, we will use \"Ohio\" as the region. \n", - "\n", - "**5. Quick links** \n", - ": As you work more frequently on the console, your frequently used services will pop up on your console, and you can also access the entire suite of AWS services via the All Services drop down. \n" + "**4. IAM Username and Organization**\n", + ": The menu bar on the console also lists your username and the current organization that you are logged into. IAM is short for Identity and Access Management. Identity is a mechanism to authenticate users (e.g. password) and Access is a mechanism for authorizing what kinds of services users have access to. In the creation of an IAM user, the administrator (overlord) of the account assigned a particular permission scope (in AWS this is known as roles) to control access to a particular set of services and also assigned a password to authenticate user login. IAM is a key component in managing security on the cloud.\n" ] }, { "cell_type": "markdown", - "id": "b2240a49", + "id": "e7ad8ac9", "metadata": {}, "source": [ "```{admonition} Exercise\n", @@ -102,22 +80,14 @@ "\n", "* What is your IAM username? \n", "* Why is IAM important?\n", - "* What are the three ways you can find an AWS service on the console?\n", + "* What are the three ways you can find an Azure service on the console?\n", "````" ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "b8fab5e4", - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -131,7 +101,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.5" + "version": "3.9.7" } }, "nbformat": 4, diff --git a/content/Azure/04_intro_to_cli.ipynb b/content/Azure/04_intro_to_cli.ipynb index 049e850..2dec232 100644 --- a/content/Azure/04_intro_to_cli.ipynb +++ b/content/Azure/04_intro_to_cli.ipynb @@ -2,43 +2,485 @@ "cells": [ { "cell_type": "markdown", - "id": "dc57021c", + "id": "bfb78c2d", "metadata": {}, "source": [ - "# Introduction to the AWS CLI\n", + "## Navigating the Command Line Interface (CLI)\n", "\n", + "Learner Questions\n", + " * How do I use the Cloud CLI?\n", + " * How do I use `az`?\n", "\n", - "```{admonition} Overview\n", - ":class: tip\n", + "Learning Objectives\n", + " * Find and use the \"Cloud Shell\" in the web console\n", + " * Use basic cloud CLI commands (`az`)\n", + " * Determine basic user/account settings.\n", + " * Use environment variables for configuration - No hard coding\n", + " * Understand the importance of using variables for configuration.\n", + " * Introduce value of reproducibility and automation." + ] + }, + { + "cell_type": "markdown", + "id": "e8cda207", + "metadata": {}, + "source": [ + "### Open the Cloud Shell\n", + "\n", + "The Cloud Shell is Debian running in a container with 5GB of no-charge persistent storage with most of the Azure tools and a lot of other useful tools (git, docker, jq, Docker, etc.) installed by default.\n", + "\n", + "To use the Azure Cloud Shell:\n", + " \n", + " * Open up a Cloud Shell by clicking on the cloud shell icon (greater than sign followed by underscore) on the blue bar just to the right of search window. On first launch, Cloud Shell prompts to create a resource group, storage account, and Azure Files share on your behalf. This will open a cloud shell at the bottum of your browser window. You can choose a bash shell or Power shell.\n", + " * If you want a new cloud shell in a different window, click the new cloud shell button (file icon with '+' in upper right corner) on the cloud shell menu bar. This will create a new cloud shell window tab. **Note:** you may need to allow popups or enable popups for this website depending on the browser you use. You can also pull up the tab to increase the shell screen size.\n", + " * To quit cloud shell type exit at the prompt." + ] + }, + { + "cell_type": "markdown", + "id": "1799e8dd", + "metadata": {}, + "source": [ + "### Exercise\n", + "Take a couple of minutes to explore your new Cloud Shell environment.\n", + " * How much RAM is available?\n", + " * How much storage is available to you?\n", + " * What is the internal IP address of the machine?\n", + " * Install your favorite editor if it is not installed." + ] + }, + { + "cell_type": "markdown", + "id": "da18d22e", + "metadata": {}, + "source": [ + "### Basic Cloud Commands\n", + "\n", + "The cloud can also be controlled using a command line interface (CLI) or a programming language such as Python. Collectively these tools interact with the cloud over a Application Programming Interface (API) and this capability forms the basis of the cloud, the ability to control infrastructure programmatically. \n", + "\n", + "For information about installing the Azure CLI for your OS see: https://docs.microsoft.com/en-us/cli/azure/install-azure-cli\n", + "\n", + "The `az` command is used to control most aspects of Azure Cloud.\n", + "\n", + "First we need to login:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1dff69af", + "metadata": {}, + "outputs": [], + "source": [ + "az login -u -p " + ] + }, + { + "cell_type": "markdown", + "id": "d7c44428", + "metadata": {}, + "source": [ + "If you want to avoid displaying your password on console and are using az login interactively, use the read -s command under bash." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "3710322e", + "metadata": {}, + "outputs": [], + "source": [ + "read -sp \"Azure password: \" AZ_PASS && echo && az login -u -p $AZ_PASS" + ] + }, + { + "cell_type": "markdown", + "id": "a0ac6e65", + "metadata": {}, + "source": [ + "or you can just use \"az login\" by itself and your default web browser will open a login window." + ] + }, + { + "cell_type": "markdown", + "id": "f7b90dba", + "metadata": {}, + "source": [ + "Now let us look at your account information. " + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "27170c24", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[\r\n", + " {\r\n", + " \"cloudName\": \"AzureCloud\",\r\n", + " \"homeTenantId\": \"67f4c504-a061-436d-ba6c-7a0fb76f6df8\",\r\n", + " \"id\": \"194bf392-269d-45de-89fc-ea9c8369fb94\",\r\n", + " \"isDefault\": false,\r\n", + " \"managedByTenants\": [],\r\n", + " \"name\": \"Azure subscription 1\",\r\n", + " \"state\": \"Enabled\",\r\n", + " \"tenantId\": \"67f4c504-a061-436d-ba6c-7a0fb76f6df8\",\r\n", + " \"user\": {\r\n", + " \"name\": \"1968posch912@gmail.com\",\r\n", + " \"type\": \"user\"\r\n", + " }\r\n", + " },\r\n", + " {\r\n", + " \"cloudName\": \"AzureCloud\",\r\n", + " \"homeTenantId\": \"78ea4b46-9f08-4ef5-949b-2dae057c55d8\",\r\n", + " \"id\": \"ae186240-1b93-42b5-bb33-e9b8c4e527de\",\r\n", + " \"isDefault\": true,\r\n", + " \"managedByTenants\": [],\r\n", + " \"name\": \"rece-dev\",\r\n", + " \"state\": \"Enabled\",\r\n", + " \"tenantId\": \"78ea4b46-9f08-4ef5-949b-2dae057c55d8\",\r\n", + " \"user\": {\r\n", + " \"name\": \"jhicks@internet2.edu\",\r\n", + " \"type\": \"user\"\r\n", + " }\r\n", + " }\r\n", + "]\r\n" + ] + } + ], + "source": [ + "!az account list" + ] + }, + { + "cell_type": "markdown", + "id": "cd6323ad", + "metadata": {}, + "source": [ + "### Environment Variables\n", + "\n", + "When using the CLI you quickly notice that you have to enter many of the details, such as a Resource Group, many times. Not only is this tedious, it also makes moving to another project difficult making reusability and collaboration painful. We will demonstrate the use environment variables to address these issues. As a reminder, environment variables used to store configuration information that can be easily passed between programs and programming languages. Most cloud environments and tools rely heavily on this technique.\n", "\n", + "We now demonstrate the basic use environment variables." + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "b8f74fe9-0943-4bd9-a91b-da09c001f8a1", + "metadata": {}, + "outputs": [], + "source": [ + "TEST=1" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "b937f6c7-3697-4bc0-8e32-da0b0faec593", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "1\n" + ] + } + ], + "source": [ + "echo $TEST" + ] + }, + { + "cell_type": "markdown", + "id": "78fe7013-a5ae-498f-aeab-ba1f3c710de1", + "metadata": {}, + "source": [ + "Although we do not always need to, we should always enclose shell variables in double quotes and enclose the variable name in curly braces (funny things may happen otherwise). In most cases it is easier to do this every time than try to figure out when it is possible to use the short form. We only use the short form here when it is used frequently and known to always work.\n", "\n", - "```" + "There are a number of environment variables already set that contain useful information, for example:" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "bae0587c-0379-40e3-9c31-16ba5505487a", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "student31\n" + ] + } + ], + "source": [ + "echo \"${USER}\"" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "52b4add5-0d18-4faf-a304-b7e0ee8ba82e", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "cs-730348008320-default-default-kp946\n" + ] + } + ], + "source": [ + "echo \"${HOSTNAME}\"" ] }, { "cell_type": "markdown", - "id": "502f2360", + "id": "ef895f38-ad16-4f2d-aa18-ec913732dd69", + "metadata": {}, + "source": [ + "We can also use the output of commands to set string values." + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "776806e4-209f-45fa-b14e-f771f5d5089d", "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Tue 24 Aug 2021 03:15:21 PM UTC\n" + ] + } + ], "source": [ - "```{code-cell} ipython3\n", - ":tags: [mytag]\n", + "date" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "id": "560fde63-0eb8-4c52-9787-4debfe35ec23", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Date: Mon Sep 27 16:49:24 EDT 2021\r\n" + ] + } + ], + "source": [ + "!echo \"Date: $(date)\"" + ] + }, + { + "cell_type": "markdown", + "id": "49c2302b", + "metadata": { + "tags": [] + }, + "source": [ + "First, as with all Azure work we need to create a Resource Group (RG). A resource group is a logical container into which Azure resources are deployed and managed. Now let us combine all of the above to create a `RG` but first let us set a RG name and region env variable so we do not need to use the actual value in future commands.\n", "\n", - "print(\"A python cell\")\n", - "```" + "Example:" + ] + }, + { + "cell_type": "markdown", + "id": "1f73131a", + "metadata": {}, + "source": [ + "Define some enviroment variables." + ] + }, + { + "cell_type": "code", + "execution_count": 47, + "id": "d00a37e4", + "metadata": {}, + "outputs": [], + "source": [ + "MYRG=\"MyResourceGroup\"\n", + "REGION=\"eastus\"" + ] + }, + { + "cell_type": "code", + "execution_count": 55, + "id": "d7988c45", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "MyResourceGroup\r\n" + ] + } + ], + "source": [ + "!echo $MYRG" + ] + }, + { + "cell_type": "code", + "execution_count": 49, + "id": "49f484a6", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{\r\n", + " \"id\": \"/subscriptions/ae186240-1b93-42b5-bb33-e9b8c4e527de/resourceGroups/MyResourceGroup\",\r\n", + " \"location\": \"eastus\",\r\n", + " \"managedBy\": null,\r\n", + " \"name\": \"MyResourceGroup\",\r\n", + " \"properties\": {\r\n", + " \"provisioningState\": \"Succeeded\"\r\n", + " },\r\n", + " \"tags\": null,\r\n", + " \"type\": \"Microsoft.Resources/resourceGroups\"\r\n", + "}\r\n" + ] + } + ], + "source": [ + "!az group create --name $MYRG --location $REGION" + ] + }, + { + "cell_type": "markdown", + "id": "7fe71e66", + "metadata": {}, + "source": [ + "Now use the `MYRG` envrionment variable to get information about your RG. This information is available at any time with the following command not just at creation." + ] + }, + { + "cell_type": "code", + "execution_count": 56, + "id": "31b01f78-94b1-44f0-a2af-d657058941b2", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{\r\n", + " \"id\": \"/subscriptions/ae186240-1b93-42b5-bb33-e9b8c4e527de/resourceGroups/MyResourceGroup\",\r\n", + " \"location\": \"eastus\",\r\n", + " \"managedBy\": null,\r\n", + " \"name\": \"MyResourceGroup\",\r\n", + " \"properties\": {\r\n", + " \"provisioningState\": \"Succeeded\"\r\n", + " },\r\n", + " \"tags\": null,\r\n", + " \"type\": \"Microsoft.Resources/resourceGroups\"\r\n", + "}\r\n" + ] + } + ], + "source": [ + "!az group show --resource-group $MYRG" + ] + }, + { + "cell_type": "markdown", + "id": "270e0abb-d5e9-476a-af91-060cc0ea0349", + "metadata": {}, + "source": [ + "### Exercise\n", + " * What command shows the project number? (hint: we used it already)\n", + " * What is the name of this variable? (hint: it is case sensitive)\n", + " * What command shows *just* the Project Number (hint: use `--format`)\n", + " * Set the `PROJECT_NUMBER` environment variable with the correct value. (hint: be careful with punctuation and matching punctuation)" ] }, { "cell_type": "code", "execution_count": null, - "id": "c543528f", + "id": "b9eebea3", "metadata": {}, "outputs": [], - "source": [] + "source": [ + "### Advanced Call-Out: Formating Output.\n", + "\n", + "The following example shows how to output the configuration as `JSON`." + ] + }, + { + "cell_type": "code", + "execution_count": 59, + "id": "678a1735-8cad-403c-b302-639de1fb0f4b", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[\r\n", + " {\r\n", + " \"id\": \"/subscriptions/ae186240-1b93-42b5-bb33-e9b8c4e527de/resourceGroups/cloud-shell-storage-eastus\",\r\n", + " \"location\": \"eastus\",\r\n", + " \"managedBy\": null,\r\n", + " \"name\": \"cloud-shell-storage-eastus\",\r\n", + " \"properties\": {\r\n", + " \"provisioningState\": \"Succeeded\"\r\n", + " },\r\n", + " \"tags\": null,\r\n", + " \"type\": \"Microsoft.Resources/resourceGroups\"\r\n", + " },\r\n", + " {\r\n", + " \"id\": \"/subscriptions/ae186240-1b93-42b5-bb33-e9b8c4e527de/resourceGroups/NetworkWatcherRG\",\r\n", + " \"location\": \"eastus\",\r\n", + " \"managedBy\": null,\r\n", + " \"name\": \"NetworkWatcherRG\",\r\n", + " \"properties\": {\r\n", + " \"provisioningState\": \"Succeeded\"\r\n", + " },\r\n", + " \"tags\": null,\r\n", + " \"type\": \"Microsoft.Resources/resourceGroups\"\r\n", + " },\r\n", + " {\r\n", + " \"id\": \"/subscriptions/ae186240-1b93-42b5-bb33-e9b8c4e527de/resourceGroups/MyResourceGroup\",\r\n", + " \"location\": \"eastus\",\r\n", + " \"managedBy\": null,\r\n", + " \"name\": \"MyResourceGroup\",\r\n", + " \"properties\": {\r\n", + " \"provisioningState\": \"Succeeded\"\r\n", + " },\r\n", + " \"tags\": null,\r\n", + " \"type\": \"Microsoft.Resources/resourceGroups\"\r\n", + " }\r\n", + "]\r\n" + ] + } + ], + "source": [ + "!az group list --output json" + ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -52,7 +494,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.5" + "version": "3.9.7" } }, "nbformat": 4,