AZ-204 Developer Associate: Architecting Powerful Compute Solutions on Azure

Last updated Jul 6, 2024 Published Jun 6, 2022

The content here is under the Attribution 4.0 International (CC BY 4.0) license

Azure offers different compute services such as Azure VMs, Azure containers, Azure functions, Azure Kubernetes and Azure app services. In this section, we will go through the compute solutions that Azure offers as well as share references to specific Microsoft documentation where more information can be fetched accordingly. The main goal here is to go over all the compute services that are listed in the exam topics, compute solutions are the biggest portion of the exam comprising 25% - 30% of the total.

Compute solutions

Azure offers tree services that developers can use to deploy applications, named:

  • Azure VMs
  • Azure app services
  • Azure functions
  • Azure containers
  • Azure Kubernetes
  • Notifications

In this section, we are going to go into every one of those and explore how to deploy them.

Azure VMs

VMs are the basic cloud service used, azure has different zones around the world to be used. Each one varies in price and availability, when using VM’s you have the following sections:

  • Basics
  • Disks
  • Networking
  • Management
  • Advanced
  • Tags

Deploy VM via CLI

First the resource group

az group create --location my-location --name myResourceGroup

And then the virtual machine with ubuntu, the following command will launch a VM that uses a public key named mysshkey.pub that already exists (via command --ssh-key-values), to generate a new key-pair along with the VM replace it by --generate--sh-keys.

az vm create \
  --resource-group myResourceGroup \
  --name myVM \
  --image UbuntuLTS \
  --admin-username azureuser \
  --ssh-key-values mysshkey.pub

Note that it is required to open up port 22 for SSH into the machine

az vm open-port --name myVM --port 22 --priority 100

For troubleshooting network issues Microsoft offers:

Availability

Virtual Machines availability is created when the VM is being configured, it will avoid downtime while doing upgrades.

App services

Web App services

Web app services are an abstraction over the app services, they are built on top of the service plans.

Note: It is possible to deploy from visual studio. refs AZ-204 - Develop Azure Compute Solutions - Azure Web Apps

Note 2: Service plan cannot host windows and linux apps together. refs AZ-204 - Develop Azure Compute Solutions - Azure Web Apps

CORS1 comes enabled by default, no other origins are able to call the service refs AZ-204 - Develop Azure Compute Solutions - Azure Web Apps

Web app settings

Deploy

Deploying a new instance of a webapp

az webapp up
az group create --location westeurope --name myResourceGroup

az appservice plan create --name $webappname --resource-group myResourceGroup --sku FREE

az webapp create --name $webappname --resource-group myResourceGroup --plan $webappname

az webapp deployment source config --name $webappname \
  --resource-group myResourceGroup \
  --repo-url $gitrepourl \
  --branch main \
  --manual-integration git clone $gitrepo \
  --plan $webapname

Integration Service Environment

ISE is a isolated environment for enterprise scale integration needs.

Databases

  • Plans

Containers

For a introduction of docker refer to docker official documentation and also for more advanced developers refer to Writing docker files tips.

The questions made in the mock exams usually mix docker concepts and azure concepts. Having a clear understanding of what each one of the things do is essential. For example, for tagging a container, the command user is from docker and not from azure cli.

  • Azure container instance
    • Provision VMs to serve containers
      • create resources
      • container instance (image)
  • Azure container registry
    • private registry
      • docker build the image
      • docker tag the image
      • log into the registry via az CLI (az acr login --name NAME_OF_REGISTRY) - registry credentials can be found in the menu keys
      • docker push the image

Use cases for containers

A resource group named FourthCoffeePublicWebResourceGroup has been created in the WestUS region that contains an App Service Plan named AppServiceLinuxDockerPlan. Which order should the CLI commands be used to develop the solution?

refs exam topics

# set the host
az webapp config hostname add --webapp-name $appName --resource-group myResourceGroup --hostname $fqdn

# create the webapp
az webapp create --name $appName --plan AppServiceLinuxDockerPlan --resource-group myResourceGroup
# set the container

azure container groups

  • containers deployed under the same machine
  • deployed via azure cli: az container create --resource-group my-group --file my-config.yml
  • azure container instance can access storage blob or file share as a volume
  • azure container instance supports secrets

Made up challenges

  1. Create a container instance from the azure CLI
  2. List containers from the Azure CLI
  3. Remove a container with Azure CLI
  4. Repeat 1 to 3 but through azure portal
  5. Deploy multiple containers

Azure Kubernetes

Kubernetes is a solution made open source that many companies use to deploy and scale computing solutions across different languages and services. Azure has its offering for Kubernetes that is deployed into Azure infrastructure.

  • Managed kubernetes on azure
  • orchestrate containers
    • cluster
    • Kubelet - an agent that runs on a node
    • pod is a group of one or more containers
    • pod gets shared resources (network, storage)
  • workloads
    • deploys via kubernetes yml file
  • services
    • deploys via kubernetes yml file
    • load balancer
  • kubectl tool
    • tool to interact with the Kubernetes cluster
    • az aks get-credentials –resource-group my-group –name my-name
      • switches the context to the aks, issuing commands locally will send them against Azure
      • kubectl get nodes
      • kubectl get pods
      • kubectl get deployments
      • kubectl get service
    • log and workspaces
      • logs are sent to the workspace and are defined in the cluster creation

Kubernetes Custom Resource Definitions (CRD)

Which CRDs should you configure? To answer, drag the appropriate CRD types to the correct locations

  • Azure function code = Deployment
  • Polling interval = Scaled object
apiVersion: keda.k8s.io/v1alpha1
kind: ScaledObject
metadata:
  name: transformer-fn
  namespace: tt
  labels:
  deploymentName: transformer-fn
spec:
  scaleTargetRef:
    deploymentName: transformer-fn
  pollingInterval: 5
  minReplicaCount: 0
  maxReplicaCount: 100
  • Azure Storage Connection String = Secret
# create the k8s demo namespace
kubectl create namespace tt

# grab connection string from Azure Service Bus
KEDA_SCALER_CONNECTION_STRING=$(az servicebus queue authorization-rule keys list \
  -g $RG_NAME \
  --namespace-name $SBN_NAME \
  --queue-name inbound \
  -n keda-scaler \
  --query "primaryConnectionString" \
  -o tsv)

# create the kubernetes secret
kubectl create secret generic tt-keda-auth --from-literal KedaScaler=$KEDA_SCALER_CONNECTION_STRING --namespace tt

Refs:

Functions

Serverless functions were born in the boom of serverless computing. Functions are one of the options that consumers are billable based on the actual computing time instead of computing availability and power (using the consumption plan) [1].

Serverless computing

For further developments of serverless computing and how it came to be the following resources are available:

Azure focused resources:

Microsoft documentation has a section that lists the serverless patterns and when to use Azure functions for a given problem.

  • Requires storage account
  • Plans
    • Pay only based on the consumption
      • pays only when the code is executed
    • App service plan
    • Always on (basic/standard plans)
      • will always be on the run state
    • Functions premium
  • the function supports docker or specific platform
  • pay only when the function is running
  • it has startup overhead - azure will remove resources if no code is running
  • triggers and bindings
    • triggers represent who will prompt the execution
      • HTTP calls
      • Timer triggers
      • Blob trigger
      • CosmosDB
    • bindings
      • react to resources that are related to the function
      • input
        • CosmosDB
          • Setting a function with HTTP trigger and CosmosDb as input, it is possible to fetch resources from CosmosDb and send them to the function as a parameter
      • output
        • Queue
          • Dispatches a message to a queue when processing the function
  • Developer tooling
    • the azure portal
    • visual studio

Note: It is possible to deploy (and run locally) from visual studio. refs AZ-204 - Develop Azure Compute Solutions - Azure Functions

  • Function settings?
  • Connection strings? predefined values
  • host.json is used to set up different logging levels and defines properties for the function that will run such as the logging level

Custom handlers can be defined if azure does not support the desired programming language.

Durable Functions

Durable has a weird meaning for azure functions, durable means a workflow, in other words, durable functions are meant to orchestrate different functions across a workflow, thus, durable.

  • Orchestration to define workflows
  • Call the same function with different parameters in an ordered fashion

Testing Azure functions locally

  • visual studio
    • provides the environment to do that already - it will open the function in localhost
  • No visual studio environments
  • CosmosDB
    • CosmosDB emulator
  • Storage
    • Azurite emulator

Function patterns

Azure functions benefit from different patterns based on the context in which the function runs:

  • Functional chaining
  • Fan-out/fan-in
  • Async HTTPS
  • Monitoring
  • Human interaction
  • Aggregator

SSL Certificates

  • Webapp
    • general settings allow for forcing HTTPS only
    • application settings override the defined properties in the application file
    • TLS/SSL settings

Authentication

  • Function
  • Anonymous
  • Admin

Footnote

References

  1. [1]S. Munoz, Exam Ref AZ-204 Developing Solutions for Microsoft Azure 2nd Edition. Microsoft Press; 2nd edition (September 18, 2020), 2020.

Changelog

  • Jul 6, 2024 - Updated content due to renewal exam