From 555071a16c1bb9e40affd545a274d234a206ac69 Mon Sep 17 00:00:00 2001 From: colinmixonn Date: Fri, 19 Aug 2022 21:39:24 +0000 Subject: [PATCH 01/11] Initial README and env.json file with az commands and global variables --- demo_scripts/containerAppsPython/README.md | 79 ++++++++++++++++++++++ demo_scripts/containerAppsPython/env.json | 8 +++ 2 files changed, 87 insertions(+) create mode 100644 demo_scripts/containerAppsPython/README.md create mode 100644 demo_scripts/containerAppsPython/env.json diff --git a/demo_scripts/containerAppsPython/README.md b/demo_scripts/containerAppsPython/README.md new file mode 100644 index 0000000..e5b8edd --- /dev/null +++ b/demo_scripts/containerAppsPython/README.md @@ -0,0 +1,79 @@ +# Create a Container App On Azure +Azure Container Apps enables you to run microservices and containerized applications on a serverless platform. + +# Prerequisites + +First we need to check you are logged in to the Azure in the CLI. The following command will check to see if you are logged in. If not it will open a browser and take you through the login steps. + +FIXME az login --scope https://management.core.windows.net//.default + +``` +echo $LOCATION +echo $RESOURCE_GROUP +az group create --name $RESOURCE_GROUP --location $LOCATION +``` +# az group delete --name $RESOURCE_GROUP --yes + + +# Step 1 - Install Azure CLI Extension + +The Azure CLI offers the capability to load extensions. +Extensions allow you gain access to experimental and pre-release commands. +Currently, Container App is in preview. + +``` +az extension add --name containerapp +``` + +# Step 2 - Register Resource Providers +Resources are manageable items available through Azure like virtual machines or storage accounts. +Resource providers supply Azure resources. +Microsoft.App is a resource provider for Contianer Apps. +Microsoft.OperationalInsights is a resource for Azure Monitor. +The `--wait` delays the next instruction until the command is completed. + +``` +az provider register --namespace Microsoft.App --wait + +az provider register --namespace Microsoft.OperationalInsights --wait +``` +# Step 3 - Create a resource group + +A resource group is a container for related resources. All resources must be placed in a resource group. We will create one for this tutorial. + +This command uses two environment variables, `RESOURCE_GROUP` is the name of the resource group and will be commonly using in other commands. `LOCATION` is the data center that the resource group will be created in. When this command has completed it will return a JSON file. You can see what the values are set at for this tutorial in that output. + +``` +echo $LOCATION +echo $RESOURCE_GROUP +az group create --name $RESOURCE_GROUP --location $LOCATION +``` + +# Step 4 - Create Azure Container Apps Environment +``` +az containerapp env create --name $CONTAINERAPPS_ENVIRONMENT --resource-group $RESOURCE_GROUP --location $LOCATION +``` +# Step 5 - Create Container App with a Public Image + + +By setting `--ingress` to external, you make the container app available to public requests. +``` +az containerapp create --name $CONTAINER_APP_NAME --resource-group $RESOURCE_GROUP --environment $CONTAINERAPPS_ENVIRONMENT --image "$CONTAINER_IMAGE" --target-port 80 --ingress 'external' +``` +# Step 6 - Test Container App with curl + +CONTAINERAPP_FQDN=$(az containerapp show --resource-group $RESOURCE_GROUP --name $CONTAINER_APP_NAME --query 'properties.configuration.ingress.fqdn' --out tsv) +``` +echo "https://${CONTAINERAPP_FQDN}" + +curl "https://${CONTAINERAPP_FQDN}" +``` +# Step 7 - Delete Resource Group + +``` +az group delete --name $RESOURCE_GROUP --yes +``` +# Done! + +Success! You now have scccessfully created a Container Apps image in Azure. + diff --git a/demo_scripts/containerAppsPython/env.json b/demo_scripts/containerAppsPython/env.json new file mode 100644 index 0000000..80c0128 --- /dev/null +++ b/demo_scripts/containerAppsPython/env.json @@ -0,0 +1,8 @@ +{ + "RESOURCE_GROUP": "my-container-apps", + "LOCATION": "eastus", + "CONTAINERAPPS_ENVIRONMENT":"my-environment", + "GITHUB_USER_OR_OR": "colinmixonn", + "CONTAINER_IMAGE":"ghcr.io/colinmixonn/serverless-python:release", + "CONTAINER_APP_NAME": "my-container-app" +} From 2cb4a67a78f219e6c8e1b457eda2c264ca3b560b Mon Sep 17 00:00:00 2001 From: colinmixonn Date: Mon, 22 Aug 2022 17:40:17 +0000 Subject: [PATCH 02/11] completed instructions for steps 1-3 --- demo_scripts/containerAppsPython/README.md | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/demo_scripts/containerAppsPython/README.md b/demo_scripts/containerAppsPython/README.md index e5b8edd..eee3be4 100644 --- a/demo_scripts/containerAppsPython/README.md +++ b/demo_scripts/containerAppsPython/README.md @@ -7,19 +7,11 @@ First we need to check you are logged in to the Azure in the CLI. The following FIXME az login --scope https://management.core.windows.net//.default -``` -echo $LOCATION -echo $RESOURCE_GROUP -az group create --name $RESOURCE_GROUP --location $LOCATION -``` -# az group delete --name $RESOURCE_GROUP --yes - - # Step 1 - Install Azure CLI Extension The Azure CLI offers the capability to load extensions. Extensions allow you gain access to experimental and pre-release commands. -Currently, Container App is in preview. +Currently, Container App is in preview so it requries an extension. ``` az extension add --name containerapp @@ -30,13 +22,14 @@ Resources are manageable items available through Azure like virtual machines or Resource providers supply Azure resources. Microsoft.App is a resource provider for Contianer Apps. Microsoft.OperationalInsights is a resource for Azure Monitor. -The `--wait` delays the next instruction until the command is completed. +The `--wait` parameter delays the next instruction until the command is completed. ``` az provider register --namespace Microsoft.App --wait az provider register --namespace Microsoft.OperationalInsights --wait ``` + # Step 3 - Create a resource group A resource group is a container for related resources. All resources must be placed in a resource group. We will create one for this tutorial. From 904d680145cabd46927bc2964cad8e9cd331a45e Mon Sep 17 00:00:00 2001 From: colinmixonn Date: Mon, 22 Aug 2022 17:48:22 +0000 Subject: [PATCH 03/11] edited intro and completed step 4 descriptions --- demo_scripts/containerAppsPython/README.md | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/demo_scripts/containerAppsPython/README.md b/demo_scripts/containerAppsPython/README.md index eee3be4..9fd23db 100644 --- a/demo_scripts/containerAppsPython/README.md +++ b/demo_scripts/containerAppsPython/README.md @@ -1,5 +1,6 @@ # Create a Container App On Azure Azure Container Apps enables you to run microservices and containerized applications on a serverless platform. +Common use cases include: Deploying API endpoints, Hosting background processing applications and more. # Prerequisites @@ -34,7 +35,9 @@ az provider register --namespace Microsoft.OperationalInsights --wait A resource group is a container for related resources. All resources must be placed in a resource group. We will create one for this tutorial. -This command uses two environment variables, `RESOURCE_GROUP` is the name of the resource group and will be commonly using in other commands. `LOCATION` is the data center that the resource group will be created in. When this command has completed it will return a JSON file. You can see what the values are set at for this tutorial in that output. +This command uses two environment variables, `RESOURCE_GROUP` is the name of the resource group and will be commonly using in other commands. +`LOCATION` is the data center that the resource group will be created in. +When this command has completed it will return a JSON file. You can see what the values are set at for this tutorial in that output. ``` echo $LOCATION @@ -43,13 +46,18 @@ az group create --name $RESOURCE_GROUP --location $LOCATION ``` # Step 4 - Create Azure Container Apps Environment +Individual container apps are deployed to a single Container Apps environment, which acts as a secure boundary around groups of container apps. +Container Apps in the same environment are deployed in the same virtual network and write logs to the same Log Analytics workspace. +This next command will create a Container App Environment in the Resource Group created in `Step 3`. + ``` +echo $CONTAINERAPPS_ENVIRONMENT az containerapp env create --name $CONTAINERAPPS_ENVIRONMENT --resource-group $RESOURCE_GROUP --location $LOCATION ``` -# Step 5 - Create Container App with a Public Image - +# Step 5 - Create Container App with a Public Image By setting `--ingress` to external, you make the container app available to public requests. + ``` az containerapp create --name $CONTAINER_APP_NAME --resource-group $RESOURCE_GROUP --environment $CONTAINERAPPS_ENVIRONMENT --image "$CONTAINER_IMAGE" --target-port 80 --ingress 'external' ``` @@ -61,12 +69,12 @@ echo "https://${CONTAINERAPP_FQDN}" curl "https://${CONTAINERAPP_FQDN}" ``` +#Success! You now have scccessfully created a Container Apps image in Azure. +If you would like to delete the resources created push any button. +If you want to keep the resources created, push `b` and CTRL + C. + # Step 7 - Delete Resource Group ``` az group delete --name $RESOURCE_GROUP --yes ``` -# Done! - -Success! You now have scccessfully created a Container Apps image in Azure. - From fad88b528e4319dcdf5d746dedcbfe55e55ec2dc Mon Sep 17 00:00:00 2001 From: colinmixonn Date: Mon, 22 Aug 2022 20:47:47 +0000 Subject: [PATCH 04/11] Completed steps 4-5. Fixing error on step 6 --- demo_scripts/containerAppsPython/README.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/demo_scripts/containerAppsPython/README.md b/demo_scripts/containerAppsPython/README.md index 9fd23db..d933dbd 100644 --- a/demo_scripts/containerAppsPython/README.md +++ b/demo_scripts/containerAppsPython/README.md @@ -6,7 +6,7 @@ Common use cases include: Deploying API endpoints, Hosting background processing First we need to check you are logged in to the Azure in the CLI. The following command will check to see if you are logged in. If not it will open a browser and take you through the login steps. -FIXME az login --scope https://management.core.windows.net//.default +#FIXME az login --scope https://management.core.windows.net//.default # Step 1 - Install Azure CLI Extension @@ -19,15 +19,15 @@ az extension add --name containerapp ``` # Step 2 - Register Resource Providers -Resources are manageable items available through Azure like virtual machines or storage accounts. -Resource providers supply Azure resources. +Resources are manageable items available through Azure like virtual machines or storage accounts. Resource providers supply Azure resources. Microsoft.App is a resource provider for Contianer Apps. Microsoft.OperationalInsights is a resource for Azure Monitor. The `--wait` parameter delays the next instruction until the command is completed. ``` az provider register --namespace Microsoft.App --wait - +``` +``` az provider register --namespace Microsoft.OperationalInsights --wait ``` @@ -49,15 +49,18 @@ az group create --name $RESOURCE_GROUP --location $LOCATION Individual container apps are deployed to a single Container Apps environment, which acts as a secure boundary around groups of container apps. Container Apps in the same environment are deployed in the same virtual network and write logs to the same Log Analytics workspace. This next command will create a Container App Environment in the Resource Group created in `Step 3`. - +Command will take ~3 minutes to complete. ``` echo $CONTAINERAPPS_ENVIRONMENT az containerapp env create --name $CONTAINERAPPS_ENVIRONMENT --resource-group $RESOURCE_GROUP --location $LOCATION ``` # Step 5 - Create Container App with a Public Image +Now that you have an environment created, you can deploy your first container app. +With the containerapp create command, deploy a container image to Azure Container Apps. +NOTE: Make sure the value for the --image parameter is in lower case. By setting `--ingress` to external, you make the container app available to public requests. - +Command will take ~3 minutes to complete. ``` az containerapp create --name $CONTAINER_APP_NAME --resource-group $RESOURCE_GROUP --environment $CONTAINERAPPS_ENVIRONMENT --image "$CONTAINER_IMAGE" --target-port 80 --ingress 'external' ``` From 7f5e0070a6d021185d6fb680620effb141c7e0e6 Mon Sep 17 00:00:00 2001 From: colinmixonn Date: Mon, 22 Aug 2022 21:02:58 +0000 Subject: [PATCH 05/11] fixing markdown syntax for simdem compatibility --- demo_scripts/containerAppsPython/README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/demo_scripts/containerAppsPython/README.md b/demo_scripts/containerAppsPython/README.md index d933dbd..bd7d11b 100644 --- a/demo_scripts/containerAppsPython/README.md +++ b/demo_scripts/containerAppsPython/README.md @@ -66,11 +66,12 @@ az containerapp create --name $CONTAINER_APP_NAME --resource-group $RESOURCE_GRO ``` # Step 6 - Test Container App with curl -CONTAINERAPP_FQDN=$(az containerapp show --resource-group $RESOURCE_GROUP --name $CONTAINER_APP_NAME --query 'properties.configuration.ingress.fqdn' --out tsv) +CONTAINERAPP_FQDN=$(az containerapp show --resource-group $RESOURCE_GROUP --name $CONTAINER_APP_NAME --query "properties.configuration.ingress.fqdn" --out tsv) ``` -echo "https://${CONTAINERAPP_FQDN}" - -curl "https://${CONTAINERAPP_FQDN}" +echo "https://$CONTAINERAPP_FQDN" +``` +``` +curl "https://$CONTAINERAPP_FQDN" ``` #Success! You now have scccessfully created a Container Apps image in Azure. If you would like to delete the resources created push any button. From e901dc3dd27f500f8ca543814aa7ca7afaaa2798 Mon Sep 17 00:00:00 2001 From: colinmixonn Date: Mon, 22 Aug 2022 22:07:35 +0000 Subject: [PATCH 06/11] step 6 and 7 are completed and succesfully run --- demo_scripts/containerAppsPython/README.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/demo_scripts/containerAppsPython/README.md b/demo_scripts/containerAppsPython/README.md index bd7d11b..7b896bb 100644 --- a/demo_scripts/containerAppsPython/README.md +++ b/demo_scripts/containerAppsPython/README.md @@ -41,7 +41,11 @@ When this command has completed it will return a JSON file. You can see what the ``` echo $LOCATION +``` +``` echo $RESOURCE_GROUP +``` +``` az group create --name $RESOURCE_GROUP --location $LOCATION ``` @@ -52,6 +56,8 @@ This next command will create a Container App Environment in the Resource Group Command will take ~3 minutes to complete. ``` echo $CONTAINERAPPS_ENVIRONMENT +``` +``` az containerapp env create --name $CONTAINERAPPS_ENVIRONMENT --resource-group $RESOURCE_GROUP --location $LOCATION ``` @@ -65,9 +71,10 @@ Command will take ~3 minutes to complete. az containerapp create --name $CONTAINER_APP_NAME --resource-group $RESOURCE_GROUP --environment $CONTAINERAPPS_ENVIRONMENT --image "$CONTAINER_IMAGE" --target-port 80 --ingress 'external' ``` # Step 6 - Test Container App with curl - +``` CONTAINERAPP_FQDN=$(az containerapp show --resource-group $RESOURCE_GROUP --name $CONTAINER_APP_NAME --query "properties.configuration.ingress.fqdn" --out tsv) ``` +``` echo "https://$CONTAINERAPP_FQDN" ``` ``` @@ -78,7 +85,7 @@ If you would like to delete the resources created push any button. If you want to keep the resources created, push `b` and CTRL + C. # Step 7 - Delete Resource Group - +The Container App and Container App Environment will be deleted with command below. ``` az group delete --name $RESOURCE_GROUP --yes ``` From 17c3f2f828f118c2a266c3f547a939c9506191ec Mon Sep 17 00:00:00 2001 From: colinmixonn Date: Mon, 22 Aug 2022 22:57:13 +0000 Subject: [PATCH 07/11] Added the instruction to change a variable name for each step --- demo_scripts/containerAppsPython/README.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/demo_scripts/containerAppsPython/README.md b/demo_scripts/containerAppsPython/README.md index 7b896bb..bff7d53 100644 --- a/demo_scripts/containerAppsPython/README.md +++ b/demo_scripts/containerAppsPython/README.md @@ -4,9 +4,8 @@ Common use cases include: Deploying API endpoints, Hosting background processing # Prerequisites -First we need to check you are logged in to the Azure in the CLI. The following command will check to see if you are logged in. If not it will open a browser and take you through the login steps. - -#FIXME az login --scope https://management.core.windows.net//.default +First we need to check you are logged in to the Azure in the CLI. The following command will check to see if you are logged in. +If not it will open a browser and take you through the login steps. # Step 1 - Install Azure CLI Extension @@ -22,8 +21,8 @@ az extension add --name containerapp Resources are manageable items available through Azure like virtual machines or storage accounts. Resource providers supply Azure resources. Microsoft.App is a resource provider for Contianer Apps. Microsoft.OperationalInsights is a resource for Azure Monitor. -The `--wait` parameter delays the next instruction until the command is completed. +The `--wait` parameter delays the next instruction until the command is completed. ``` az provider register --namespace Microsoft.App --wait ``` @@ -53,6 +52,7 @@ az group create --name $RESOURCE_GROUP --location $LOCATION Individual container apps are deployed to a single Container Apps environment, which acts as a secure boundary around groups of container apps. Container Apps in the same environment are deployed in the same virtual network and write logs to the same Log Analytics workspace. This next command will create a Container App Environment in the Resource Group created in `Step 3`. + Command will take ~3 minutes to complete. ``` echo $CONTAINERAPPS_ENVIRONMENT @@ -66,11 +66,14 @@ Now that you have an environment created, you can deploy your first container ap With the containerapp create command, deploy a container image to Azure Container Apps. NOTE: Make sure the value for the --image parameter is in lower case. By setting `--ingress` to external, you make the container app available to public requests. + Command will take ~3 minutes to complete. ``` az containerapp create --name $CONTAINER_APP_NAME --resource-group $RESOURCE_GROUP --environment $CONTAINERAPPS_ENVIRONMENT --image "$CONTAINER_IMAGE" --target-port 80 --ingress 'external' ``` # Step 6 - Test Container App with curl +The `az containerapp show` command returns the fully qualified domain name of a container app. +In the next command we are setting the domain name to the variable `CONTAINERAPP_FQDN` ``` CONTAINERAPP_FQDN=$(az containerapp show --resource-group $RESOURCE_GROUP --name $CONTAINER_APP_NAME --query "properties.configuration.ingress.fqdn" --out tsv) ``` @@ -80,12 +83,14 @@ echo "https://$CONTAINERAPP_FQDN" ``` curl "https://$CONTAINERAPP_FQDN" ``` + #Success! You now have scccessfully created a Container Apps image in Azure. If you would like to delete the resources created push any button. -If you want to keep the resources created, push `b` and CTRL + C. +If you want to keep the resources created, push `b` and `CTRL + C` to exit the program. # Step 7 - Delete Resource Group The Container App and Container App Environment will be deleted with command below. + ``` az group delete --name $RESOURCE_GROUP --yes ``` From 7c21e1e1e14c7b280ca8116b0d255092a0b453cc Mon Sep 17 00:00:00 2001 From: colinmixonn Date: Wed, 24 Aug 2022 00:08:16 +0000 Subject: [PATCH 08/11] Added better CLI login instructions and added instructions to change variables and added link to execute prereqs --- demo_scripts/containerAppsPython/README.md | 36 ++++++++++++++++++---- demo_scripts/containerAppsPython/env.json | 5 +-- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/demo_scripts/containerAppsPython/README.md b/demo_scripts/containerAppsPython/README.md index bff7d53..426e78a 100644 --- a/demo_scripts/containerAppsPython/README.md +++ b/demo_scripts/containerAppsPython/README.md @@ -2,17 +2,28 @@ Azure Container Apps enables you to run microservices and containerized applications on a serverless platform. Common use cases include: Deploying API endpoints, Hosting background processing applications and more. -# Prerequisites - +# Azure CLI Login First we need to check you are logged in to the Azure in the CLI. The following command will check to see if you are logged in. If not it will open a browser and take you through the login steps. -# Step 1 - Install Azure CLI Extension +To Login to Az CLI and select a subscription +`az login` followed by `az account list --output table` and `az account set --subscription "name of subscription to use"` + +To Install Az CLI +If you need to install Azure CLI run the following command: curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash + +# Prerequisites +Before you can begin you need to follow the prerequisite steps found here +``` +echo https://github.com/Azure-Samples/azure-opensource-labs/$PREREQUISITES +``` + +# Step 1 - Install Azure CLI Extension The Azure CLI offers the capability to load extensions. Extensions allow you gain access to experimental and pre-release commands. -Currently, Container App is in preview so it requries an extension. +Currently, Container App is in preview so it requries an extension. ``` az extension add --name containerapp ``` @@ -31,13 +42,14 @@ az provider register --namespace Microsoft.OperationalInsights --wait ``` # Step 3 - Create a resource group - A resource group is a container for related resources. All resources must be placed in a resource group. We will create one for this tutorial. This command uses two environment variables, `RESOURCE_GROUP` is the name of the resource group and will be commonly using in other commands. `LOCATION` is the data center that the resource group will be created in. -When this command has completed it will return a JSON file. You can see what the values are set at for this tutorial in that output. +When this command has completed it will return a JSON file. +You can see what the variables are set at for this tutorial in that output. +If you want to change them press `b` and run the command export `VARIABLE_NAME="new variable value"` ``` echo $LOCATION ``` @@ -54,6 +66,9 @@ Container Apps in the same environment are deployed in the same virtual network This next command will create a Container App Environment in the Resource Group created in `Step 3`. Command will take ~3 minutes to complete. + +You can see what the variables are set at for this tutorial in that output. +If you want to change them press `b` and run the command export `VARIABLE_NAME="new variable value"` ``` echo $CONTAINERAPPS_ENVIRONMENT ``` @@ -68,6 +83,15 @@ NOTE: Make sure the value for the --image parameter is in lower case. By setting `--ingress` to external, you make the container app available to public requests. Command will take ~3 minutes to complete. + +You can see what the variables are set at for this tutorial in that output. +If you want to change them press `b` and run the command export `VARIABLE_NAME="new variable value"` +``` +echo $CONTAINER_APP_NAME +``` +``` +echo $CONTAINER_IMAGE +``` ``` az containerapp create --name $CONTAINER_APP_NAME --resource-group $RESOURCE_GROUP --environment $CONTAINERAPPS_ENVIRONMENT --image "$CONTAINER_IMAGE" --target-port 80 --ingress 'external' ``` diff --git a/demo_scripts/containerAppsPython/env.json b/demo_scripts/containerAppsPython/env.json index 80c0128..0e910a7 100644 --- a/demo_scripts/containerAppsPython/env.json +++ b/demo_scripts/containerAppsPython/env.json @@ -2,7 +2,8 @@ "RESOURCE_GROUP": "my-container-apps", "LOCATION": "eastus", "CONTAINERAPPS_ENVIRONMENT":"my-environment", - "GITHUB_USER_OR_OR": "colinmixonn", + "GITHUB_USER_OR_ORG": "colinmixonn", "CONTAINER_IMAGE":"ghcr.io/colinmixonn/serverless-python:release", - "CONTAINER_APP_NAME": "my-container-app" + "CONTAINER_APP_NAME": "my-container-app", + "PREREQUISITES": "tree/main/cloud-native/containerapps-github-python#1-build-and-containerize-asw101python-fastapi-pypy" } From 132561af37f3279f6d72418a8d89fad1eb7a86f3 Mon Sep 17 00:00:00 2001 From: colinmixonn Date: Thu, 25 Aug 2022 17:24:50 +0000 Subject: [PATCH 09/11] Removed the hardcoded GITHUB USERNAME from .json file and added it to README as a user filled variable and respective instructions. Renumbered steps --- demo_scripts/containerAppsPython/README.md | 21 +++++++++++++++++---- demo_scripts/containerAppsPython/env.json | 2 -- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/demo_scripts/containerAppsPython/README.md b/demo_scripts/containerAppsPython/README.md index 426e78a..58795f5 100644 --- a/demo_scripts/containerAppsPython/README.md +++ b/demo_scripts/containerAppsPython/README.md @@ -75,8 +75,20 @@ echo $CONTAINERAPPS_ENVIRONMENT ``` az containerapp env create --name $CONTAINERAPPS_ENVIRONMENT --resource-group $RESOURCE_GROUP --location $LOCATION ``` - -# Step 5 - Create Container App with a Public Image +# Step 5 - Input GitHub Username for an Individual or organization +For the next step we need to use your GitHub username to connect to the Container Image. +The current value for GITHUB_USERNAME is empty. See below. +``` +echo $GITHUB_USERNAME +``` +Press `b` and run the command `GITHUB_USERNAME="username"` to set variable. +``` +echo $GITHUB_USERNAME +``` +``` +CONTAINER_IMAGE=ghcr.io/$GITHUB_USERNAME/serverless-python:release +``` +# Step 6 - Create Container App with a Public Image Now that you have an environment created, you can deploy your first container app. With the containerapp create command, deploy a container image to Azure Container Apps. NOTE: Make sure the value for the --image parameter is in lower case. @@ -95,7 +107,8 @@ echo $CONTAINER_IMAGE ``` az containerapp create --name $CONTAINER_APP_NAME --resource-group $RESOURCE_GROUP --environment $CONTAINERAPPS_ENVIRONMENT --image "$CONTAINER_IMAGE" --target-port 80 --ingress 'external' ``` -# Step 6 - Test Container App with curl + +# Step 7 - Test Container App with curl The `az containerapp show` command returns the fully qualified domain name of a container app. In the next command we are setting the domain name to the variable `CONTAINERAPP_FQDN` ``` @@ -112,7 +125,7 @@ curl "https://$CONTAINERAPP_FQDN" If you would like to delete the resources created push any button. If you want to keep the resources created, push `b` and `CTRL + C` to exit the program. -# Step 7 - Delete Resource Group +# Step 8 - Delete Resource Group The Container App and Container App Environment will be deleted with command below. ``` diff --git a/demo_scripts/containerAppsPython/env.json b/demo_scripts/containerAppsPython/env.json index 0e910a7..e99a5b6 100644 --- a/demo_scripts/containerAppsPython/env.json +++ b/demo_scripts/containerAppsPython/env.json @@ -2,8 +2,6 @@ "RESOURCE_GROUP": "my-container-apps", "LOCATION": "eastus", "CONTAINERAPPS_ENVIRONMENT":"my-environment", - "GITHUB_USER_OR_ORG": "colinmixonn", - "CONTAINER_IMAGE":"ghcr.io/colinmixonn/serverless-python:release", "CONTAINER_APP_NAME": "my-container-app", "PREREQUISITES": "tree/main/cloud-native/containerapps-github-python#1-build-and-containerize-asw101python-fastapi-pypy" } From d57647a146945aaa5e7803d680a30d64395008a6 Mon Sep 17 00:00:00 2001 From: colinmixonn Date: Thu, 25 Aug 2022 18:05:05 +0000 Subject: [PATCH 10/11] Added steps for prereq stage. Moved the user filled GITHUB_USERNAME step to prereqs. changed numbering. Added styling throughout --- demo_scripts/containerAppsPython/README.md | 47 +++++++++++++--------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/demo_scripts/containerAppsPython/README.md b/demo_scripts/containerAppsPython/README.md index 58795f5..679a9bd 100644 --- a/demo_scripts/containerAppsPython/README.md +++ b/demo_scripts/containerAppsPython/README.md @@ -15,8 +15,21 @@ If you need to install Azure CLI run the following command: curl -sL https://aka # Prerequisites Before you can begin you need to follow the prerequisite steps found here + +1. Visit https://github.com/asw101/python-fastapi-pypy +2. Click "Use this template" +3. Name your repo "serverless-python". + * **If your GitHub repository Private rather than Public in step 3, you will need to click on "Package settings" on the right hand side, scroll down and click "Change visibility" button to make your package public.** +4. Create a new branch called release +5. Click on the Actions tab +6. View the output of the action +7. Return to the main repo (Code tab) +8. Click on "serverless-python" under "Packages" on the right hand side +9. Copy the `docker pull` command which will include the image name +10. Update the `GITHUB_USERNAME` environment variable below with your GitHub username or organization name. + * **Press `b` and run the command `GITHUB_USERNAME="username"` to set variable.** ``` -echo https://github.com/Azure-Samples/azure-opensource-labs/$PREREQUISITES +echo $GITHUB_USERNAME ``` # Step 1 - Install Azure CLI Extension @@ -65,7 +78,7 @@ Individual container apps are deployed to a single Container Apps environment, w Container Apps in the same environment are deployed in the same virtual network and write logs to the same Log Analytics workspace. This next command will create a Container App Environment in the Resource Group created in `Step 3`. -Command will take ~3 minutes to complete. +**Command will take ~3 minutes to complete.** You can see what the variables are set at for this tutorial in that output. If you want to change them press `b` and run the command export `VARIABLE_NAME="new variable value"` @@ -75,30 +88,24 @@ echo $CONTAINERAPPS_ENVIRONMENT ``` az containerapp env create --name $CONTAINERAPPS_ENVIRONMENT --resource-group $RESOURCE_GROUP --location $LOCATION ``` -# Step 5 - Input GitHub Username for an Individual or organization -For the next step we need to use your GitHub username to connect to the Container Image. -The current value for GITHUB_USERNAME is empty. See below. -``` -echo $GITHUB_USERNAME -``` -Press `b` and run the command `GITHUB_USERNAME="username"` to set variable. -``` -echo $GITHUB_USERNAME -``` -``` -CONTAINER_IMAGE=ghcr.io/$GITHUB_USERNAME/serverless-python:release -``` -# Step 6 - Create Container App with a Public Image + +# Step 5 - Create Container App with a Public Image Now that you have an environment created, you can deploy your first container app. With the containerapp create command, deploy a container image to Azure Container Apps. -NOTE: Make sure the value for the --image parameter is in lower case. +*NOTE: Make sure the value for the --image parameter is in lower case.* By setting `--ingress` to external, you make the container app available to public requests. -Command will take ~3 minutes to complete. +**Command will take ~3 minutes to complete.** You can see what the variables are set at for this tutorial in that output. If you want to change them press `b` and run the command export `VARIABLE_NAME="new variable value"` ``` +echo $GITHUB_USERNAME +``` +``` +CONTAINER_IMAGE=ghcr.io/$GITHUB_USERNAME/serverless-python:release +``` +``` echo $CONTAINER_APP_NAME ``` ``` @@ -108,7 +115,7 @@ echo $CONTAINER_IMAGE az containerapp create --name $CONTAINER_APP_NAME --resource-group $RESOURCE_GROUP --environment $CONTAINERAPPS_ENVIRONMENT --image "$CONTAINER_IMAGE" --target-port 80 --ingress 'external' ``` -# Step 7 - Test Container App with curl +# Step 6 - Test Container App with curl The `az containerapp show` command returns the fully qualified domain name of a container app. In the next command we are setting the domain name to the variable `CONTAINERAPP_FQDN` ``` @@ -125,7 +132,7 @@ curl "https://$CONTAINERAPP_FQDN" If you would like to delete the resources created push any button. If you want to keep the resources created, push `b` and `CTRL + C` to exit the program. -# Step 8 - Delete Resource Group +# Step 7 - Delete Resource Group The Container App and Container App Environment will be deleted with command below. ``` From e756ddcd244e43ef57715c46fed4731ebff036e1 Mon Sep 17 00:00:00 2001 From: colinmixonn Date: Thu, 25 Aug 2022 18:08:23 +0000 Subject: [PATCH 11/11] changed markdown syntax. small change --- demo_scripts/containerAppsPython/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo_scripts/containerAppsPython/README.md b/demo_scripts/containerAppsPython/README.md index 679a9bd..dd3c646 100644 --- a/demo_scripts/containerAppsPython/README.md +++ b/demo_scripts/containerAppsPython/README.md @@ -128,7 +128,7 @@ echo "https://$CONTAINERAPP_FQDN" curl "https://$CONTAINERAPP_FQDN" ``` -#Success! You now have scccessfully created a Container Apps image in Azure. +# Success! You now have scccessfully created a Container Apps image in Azure. If you would like to delete the resources created push any button. If you want to keep the resources created, push `b` and `CTRL + C` to exit the program.