Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save joelowrance/c514f673233ab3b588c06e70967916fb to your computer and use it in GitHub Desktop.

Select an option

Save joelowrance/c514f673233ab3b588c06e70967916fb to your computer and use it in GitHub Desktop.
6- Deploy and run a containerized web app with Azure App Service

Build and store images by using Azure Container Registry

ACR allows you to store containers in the cloud (Azure version of Dockerhub)

What is Container Registry?

Service to store your own private Docker registries More secure than docker hub

  • you set permissions
  • you can sign images
  • images are encrypted

Using Container Registry

Create with CLI or in the portal

az acr create --name myregistry --resource-group mygroup --sku standard --admin-enabled true

ACR stores images, but can also be used to build images.

az acr build --file Dockerfile --registry myregistry --image myimage . this command sends the folder to AZ, which uses the dockerfile to build the image. The . at the end is the path

Exercise - Build and store an image by using Azure Container Registry

Created ACR in portal, clone repo and push the contents using the CLI

Deploy a web app by using an image from an Azure Container Registry repository

Deploy a web app from a repository in Azure Container Registry

Web app from docker image needs the following

  • the registry (ACR, docker hub)
  • the image
  • the tag (latest is the convention)
  • startup file (exe or command to run)

Exercise - Create and deploy a web app from a Docker image

Like creating a regular web app, except you pick container. The wizard then lets you pick your image from the ACR registry. When you click create, AZ pulls from the container and the site is live.

Update the image and automatically redeploy the web app

What is a webhook?

App Service subscribes to ACR to rec. notifications that something has changed, then the new version is automatically pulled in and deployed.

What is the Container Registry tasks feature?

Use to rebuild image whenever source changes.

Enable continuous integration from App Service

On the container settings page you pick continuous deployment

Extend continuous integration to source control by using a Container Registry task

Tasks must be created from the command line using az acr task create

az acr task create --registry <container_registry_name> --name buildwebapp --image webimage --context https://github.com/MicrosoftDocs/mslearn-deploy-run-container-app-service.git --branch master --file Dockerfile --git-access-token <access_token>

This creates a task called buildwebapp which monitors GH. When changes are checked in, the task runs.

Exercise - Modify the image and redeploy the web app

Made a change to source code, pushed changes to ACR. ACR built the image and the webhook was triggered and the site was updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment