Using Azure Web Apps with Containers, Linux, and Cloud Shell

Hands-On Lab

 

Photo of Jason Calton

Jason Calton

Training Architect

Length

00:30:00

Difficulty

Intermediate

In this lab, you will gain experience using the Azure Cloud Shell to create App Service plans using Linux, and web apps using Docker containers. You will use the Azure Cloud Shell to create a Linux App Service plan, and a web app under that plan which uses Docker images on DockerHub and GitHub. When you're finished, you will browse to your site to see everything running and will verify all the resources you created using the Azure Portal. Upon completion of the lab, you will have gained the experience required to use the Azure Cloud Shell to create App Service plans using Linux and web apps using Docker containers.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Using Azure Web Apps with Containers, Linux, and Cloud Shell

Introduction

In this lab, you will gain experience using the Azure Cloud Shell to create App Service plans using Linux, and web apps that use Docker containers.

You will use the Azure Cloud Shell to create a Linux App Service plan, and a web app under that plan which uses Docker images on DockerHub and GitHub. When you're finished, you will browse to your site to see everything running, and will verify all the resources you created using the Azure Portal.

Getting Started

Log in to the Azure Portal using the credentials and link provided in the Credentials section on the hands-on lab page.

Use Cloud Shell to Create and Update Linux App Service Plans and Web Apps

Use Cloud Shell to Create a Linux App Service Plan

Right-click the Azure Portal tab in your browser and choose the Duplicate Tab option. In this new tab, open the Azure Cloud Shell using the icon in the top menu.

Choose PowerShell when you are prompted. For our storage options, choose Show advanced settings.

Ensure that the following fields are provided for the advanced settings:

  • Cloud Shell region: South Central US
  • Storage Account: Click Use existing
  • File Share: Click Create new and use any random name

With these options configured, click Create Stroage.

Copy the PowerShell commands below and paste them into your Cloud Shell window:

$resourceGroup = az group list --query '[0].name' --output json
$appServicePlan = 'Linux-App-ServicePlan'

az appservice plan create -g $resourceGroup -n $appServicePlan --is-linux --number-of-workers 1 --sku B1

Use Cloud Shell to Create a Web App Using a DockerHub Container Image

Copy the PowerShell commands below and paste them into your Cloud Shell window:

$app = 'LinuxDockerApp' + (Get-Date).ticks

az webapp create --resource-group $resourceGroup --plan $appServicePlan --name $app --deployment-container-image-name microsoft/dotnet-samples:aspnetapp

We can verify this by navigating to our Azure Portal tab. Click All Resources and then click on our Docker App Service in the list of resources. In the Settings section, click Container settings and note the Image source is set to Docker Hub.

Use Cloud Shell to Update a Web App Container Image from DockerHub to GitHub

Copy the PowerShell command below and paste it into your Cloud Shell window:

az webapp config container set --resource-group $resourceGroup --name $app --docker-registry-server-url 'https://github.com/dotnet/dotnet-docker/tree/master/samples/aspnetapp'

We can verify that this command ran successfully by navigating back to the Azure Portal. Refresh the Container settings page. Our Image source now shows as Private Registry and the Server URL is the same URL we provided in our command.

We can verify that our site is running by clicking Overview in the App Service menu. Our endpoint is shown in the URL section on this page. Click on this URL to load our app and verify that it is running.

Conclusion

Congratulations on completing this hands-on lab!