Skip to content

Latest commit

 

History

History
103 lines (70 loc) · 4.25 KB

4.3.5-aci.md

File metadata and controls

103 lines (70 loc) · 4.25 KB
docs/4-cloud-computing/4.3.5-aci.md
category estReadingMinutes exercises
Cloud Computing
10
name description estMinutes technologies
Deploy Node app using Docker, ACR, and ACI
Create a docker image for your Node application. Push your image into ACR. Then deploy your image via ACI.
360
Azure
Azure Container Instances (ACI)
Azure Container Registry (ACR)
Docker
Node.js

Azure Container Instances (ACI)

While building VMs and VM scale sets are appropriate in some cases, this would probably be a wasteful approach to deploy a small Node.js application. Instead of deploying an entire server to host our application, we will package our small application in a Docker image and launch an instance in ACI.

Azure Container Instances provides a fast and simple way to run containers in Azure, without having to manage any virtual machines and without having to adopt a higher-level service. When more complicated scenarios are required, such as service discovery across multiple containers, automatic scaling, and coordinated application upgrades, it is best to use Azure Kubernetes Service (AKS) instead of ACI. We will cover AKS in the next section. It is actually possible to use ACI as burst capacity for AKS, so the solutions are not mutually exclusive.

Azure Container Registry is used to build, store, secure, scan, and replicate container images and artifacts. It is often used in combination with ACI and AKS.

Create a Docker image and launch an instance in ACI

  1. We will use the same Node.js app as the previous sections.
mkdir /Users/YOUR_NAME/aci-bootcamp
mv /Users/YOUR_NAME/webapp /Users/YOUR_NAME/aci-bootcamp/
  1. Create Dockerfile.
FROM node:8.9.3-alpine
RUN mkdir -p /usr/src/app
COPY webapp/ /usr/src/app/
WORKDIR /usr/src/app
RUN npm install
CMD node /usr/src/app/index.js
EXPOSE 3000
  1. Build the Docker image locally.

?> ACI architecture is x86. Make sure your container is compiled for x86. docker inspect --format='{{.Os}}/{{.Architecture}}' <my_image> should show linux/amd64

  1. Run the container locally to make sure it works.

?> You will need to map the port the container is listening on (TCP 3000) to a port on your local machine in order to test.

  1. Log into Azure CLI and select the correct subscription.

  2. Create a resource group for ACR and ACI resources.

  3. Create an ACR instance to host our Docker images.

REGISTRY_NAME=YOUR_NAMEbootcamp
az acr -h

?> Registry names must be globally unique.

  1. Log into the ACR instance.
az acr login --name $REGISTRY_NAME
  1. Get the server address of your ACR instance (az acr show -h) and store it in DOCKER_SERVER.

  2. Tag the image and push to ACR.

?> The tag for the image does not need to be specific, only needs to be consistant

  1. Use Azure CLI to List images in your ACR instance and make sure your Docker push was successful.

  2. Create a service principles to use with ACR. Click here to learn more about service principal objects in Azure AD.

?> You need owner role or equivalent permissions on a subscription to create service principals. If you don't have access, you may want to do this short lab in your free Microsoft account.

  1. Launch an instance in ACR.
az container -h

?> Locate the credentials for you Azure Container Registry using the portal

  1. Use Azure CLI to check the deployment status, access container logs, and test access to the site.

  2. Clean up resources and delete the service principal.

Deliverables

  • What permissions are required to create service principals, and how might this affect someone working on a free Microsoft account?
  • How do you ensure that your container is compiled for x86 architecture, as required by ACI?
  • What function does the Azure Container Registry (ACR) serve in the context of container management? Does it only need ACR?
  • How are Azure Container Instances (ACI) and Azure Kubernetes Service (AKS) related, and in what scenarios might you choose one over the other?