Skip to content

Instantly share code, notes, and snippets.

@Mirakurun
Last active September 18, 2023 00:40
Show Gist options
  • Save Mirakurun/57112b375f6efed509a72f7482ba84b1 to your computer and use it in GitHub Desktop.
Save Mirakurun/57112b375f6efed509a72f7482ba84b1 to your computer and use it in GitHub Desktop.
AZ-204: Developing Solutions for Microsoft Azure

📝 AZ-204 Notes

📑 Table of Contents

Expand
  1. Develop Azure compute solutions (25–30%)
    1. Implement containerized solutions
      1. Create and manage container images for solutions - WIP
      2. Publish an image to the Azure Container Registry
        1. Push your first image to your Azure container registry using the Docker CLI
      3. Run containers by using Azure Container Instance
        1. Deploy a container instance by using the Azure CLI
          1. Container restart policy
          2. Set environment variables in container instances
      4. Create solutions by using Azure Container Apps - WIP
      5. Provision virtual machines in Azure - Deprecated
        1. Create a virtual machine by using the Azure CLI
        2. Create and Manage Windows VMs with Azure PowerShell
        3. Generate and store SSH keys with the Azure CLI
      6. Configure container images for solutions - Deprecated
        1. Build and run a container image by using Azure Container Registry Tasks
    2. Implement Azure Functions
      1. Create and configure an Azure Function App
        1. Create a function in the Azure portal
      2. Implement input and output bindings
      3. Implement function triggers by using data operations, timers, and webhooks
  2. Develop for Azure storage (15–20%)
    1. Develop solutions that use Azure Cosmos DB
      1. Perform operations on containers and items by using the SDK - WIP
      2. Set the appropriate consistency level for operations
        1. Consistency levels in Azure Cosmos DB
      3. Implement change feed notifications
    2. Develop solutions that use Azure Blob Storage
      1. Set and retrieve properties and metadata
      2. Perform operations on data by using the appropriate SDK
      3. Implement storage policies and data lifecycle management
      4. Implement static site hosting
  3. Implement Azure security (20–25%)
    1. Implement user authentication and authorization
      1. Authenticate and authorize users by using the Microsoft Identity platform
      2. Authenticate and authorize users and apps by using Microsoft Azure Active Directory (Azure AD), part of Microsoft Entra
      3. Create and implement shared access signatures
      4. Implement solutions that interact with Microsoft Graph
    2. Implement secure Azure solutions

Develop Azure compute solutions (25–30%)

  • Implement containerized solutions
  • Implement Azure App Service Web Apps
  • Implement Azure Functions

🏗️ Implement containerized solutions

Expand

🧪 Lab 05: Deploy compute workloads by using images and containers ↗️

🚢 Publish an image to the Azure Container Registry

Push your first image to your Azure container registry using the Docker CLI ↗️

  1. Create a resource group.

  2. Create a container registry.

  3. Log in to a registry.

    # az acr login --name <acrName>
    az acr login --name az204-acr-registry
  4. Push image to Azure Container Registry.

    # docker push <acrLoginServer>/<nameSpace>/<repoName>:<tag>
    docker push az204-acr-registry.azurecr.io/samples/nginx:v1

🖥️ Provision virtual machines in Azure - Deprecated

Create a virtual machine by using the Azure CLI

  1. Create a resource group with the az group create command.

    az group create --name az204-vm-rg --location westus
  2. Create a VM with the az vm create command.

    az vm create \
        --resource-group az204-vm-rg \
        --name az204vm \
        --image UbuntuLTS \
        --generate-ssh-keys \
        --admin-username azureuser \
        --public-ip-sku Standard
  1. Create a resource group.

    New-AzResourceGroup `
      -ResourceGroupName "myResourceGroupVM" `
      -Location "EastUS"
  2. Create a VM

    1. Set the username and password needed for the administrator account on the VM with Get-Credential.

      $cred = Get-Credential
    2. Create the VM with New-AzVM.

      New-AzVm `
          -ResourceGroupName "myResourceGroupVM" `
          -Name "myVM" `
          -Location "EastUS" `
          -VirtualNetworkName "myVnet" `
          -SubnetName "mySubnet" `
          -SecurityGroupName "myNetworkSecurityGroup" `
          -PublicIpAddressName "myPublicIpAddress" `
          -Credential $cred
az sshkey create --location "westus" --resource-group "myResourceGroup" --name "mySshPublicKeyName"

⚙️ Configure container images for solutions

  1. Create a resource group.

    az group create --name az204-acr-rg --location westus
  2. Create a container registry.

    az acr create --resource-group az204-acr-rg --name az204-acr-registry --sku Basic --location westus
  3. Create a Dockerfile.

  4. Run the az acr build command to perform a quick task (Think docker build, docker push in the cloud).

    az acr build --image sample/hello-world:v1 --registry az204-acr-registry .

📦 Run containers by using Azure Container Instance

  1. Create a resource group.

  2. You'll provide a DNS name to expose your container to the Internet. Your DNS name must be unique. For learning purposes, run this command from Cloud Shell to create a Bash variable that holds a unique name.

    DNS_NAME_LABEL=aci-demo-$RANDOM
  3. Run the following az container create command to start a container instance.

    az container create \
        --resource-group az204-acr-rg \
        --name mycontainer \
        --image mcr.microsoft.com/azuredocs/aci-helloworld \
        --ports 80 \
        --dns-name-label $DNS_NAME_LABEL \
        --location westus
  4. When the az container create command completes, run az container show to check its status.

    az container show \
        --resource-group az204-acr-rg \
        --name mycontainer \
        --query "{FQDN:ipAddress.fqdn,ProvisioningState:provisioningState}" \
        --output table

    You see your container's fully qualified domain name (FQDN) and its provisioning state. Here's an example.

    FQDN                                    ProvisioningState
    --------------------------------------  -------------------
    aci-demo-0000.westus.azurecontainer.io  Succeeded

    When you create a container group in Azure Container Instances, you can specify one of three restart policy settings.

    Restart policy Description
    Always Containers in the container group are always restarted. This is the default setting applied when no restart policy is specified at container creation.
    Never Containers in the container group are never restarted. The containers run at most once.
    OnFailure Containers in the container group are restarted only when the process executed in the container fails (when it terminates with a nonzero exit code). The containers are run at least once.

    Specify a restart policy

    Specify the --restart-policy parameter when you call az container create.

    az container create \
        --resource-group az204-acr-rg \
        --name mycontainer \
        --image mycontainerimage \
        --restart-policy OnFailure
    az container create \
        --resource-group az204-acr-rg \
        --name mycontainer \
        --image myimage:latest \
        --environment-variables key1=value1 key2=value2

Deploy a container instance in Azure using Azure PowerShell ↗️

  1. Create a resource group.

  2. Create a container.

    New-AzContainerGroup `
        -ResourceGroupName "myResourceGroup" `
        -Name "mycontainer" `
        -Image "mcr.microsoft.com/windows/servercore/iis:nanoserver" `
        -OsType "Windows" `
        -DnsNameLabel "aci-demo-win"
  3. Within a few seconds, you should receive a response from Azure. The container's ProvisioningState is initially Creating, but should move to Succeeded within a minute or two. Check the deployment state with the Get-AzContainerGroup cmdlet.

    Get-AzContainerGroup -ResourceGroupName myResourceGroup -Name mycontainer

    The container's provisioning state, fully qualified domain name (FQDN), and IP address appear in the cmdlet's output.

    ResourceGroupName        : myResourceGroup
    Id                       : /subscriptions/<Subscription ID>/resourceGroups/myResourceGroup/providers/Microsoft.ContainerInstance/containerGroups/mycontainer
    Name                     : mycontainer
    Type                     : Microsoft.ContainerInstance/containerGroups
    Location                 : eastus
    Tags                     :
    ProvisioningState        : Creating
    Containers               : {mycontainer}
    ImageRegistryCredentials :
    RestartPolicy            : Always
    IpAddress                : 52.226.19.87
    DnsNameLabel             : aci-demo-win
    Fqdn                     : aci-demo-win.eastus.azurecontainer.io
    Ports                    : {80}
    OsType                   : Windows
    Volumes                  :
    State                    : Pending
    Events                   : {}

⚡ Implement Azure Functions

Expand

Lab 02: Implement task processing logic by using Azure Functions ↗️

Create and configure an Azure Function App

  1. From the Azure portal menu or the Home page, select Create a resource.
  2. In the New page, select Compute > Function App.
  3. On the Basics page, use the function app settings as specified in the following table ↗️.
  4. Accept the default options of creating a new storage account on the Storage tab and a new Application Insight instance on the Monitoring tab. You can also choose to use an existing storage account or Application Insights instance.
  5. Select Review + create to review the app configuration you chose, and then select Create to provision and deploy the function app.
  6. Select the Notifications icon in the upper-right corner of the portal and watch for the Deployment succeeded message.
  7. Select Go to resource to view your new function app. You can also select Pin to dashboard. Pinning makes it easier to return to this function app resource from your dashboard.

Next, create a function in the new function app.

Implement input and output bindings

Develop for Azure storage (15–20%)

  • Develop solutions that use Azure Cosmos DB
  • Develop solutions that use Azure Blob Storage

Develop solutions that use Azure Cosmos DB

Expand

🧪 Lab 04: Construct a polyglot data solution ↗️

Perform operations on containers and items by using the SDK

Set the appropriate consistency level for operations

Develop solutions that use Azure Blob Storage

Expand

🧪 Lab 03: Retrieve Azure Storage resources and metadata by using the Azure Storage SDK for .NET ↗️

Implement storage policies and data lifecycle management

Implement Azure security (20–25%)

  • Implement user authentication and authorization
  • Implement secure Azure solutions

Implement user authentication and authorization

Expand

🧪 Lab 06: Authenticate by using OpenID Connect, MSAL, and .NET SDKs ↗️

Authenticate and authorize users by using the Microsoft Identity platform

Authenticate and authorize users and apps by using Microsoft Azure Active Directory (Azure AD), part of Microsoft Entra

Create and implement shared access signatures

Implement solutions that interact with Microsoft Graph

Implement secure Azure solutions

Expand

🧪 Lab 07: Access resource secrets more securely across services ↗️

Secure app configuration data by using App Configuration or Azure Key Vault

Develop code that uses keys, secrets, and certificates stored in Azure Key Vault

Implement Managed Identities for Azure resources

Monitor, troubleshoot, and optimize Azure solutions (15–20%)

  • Implement caching for solutions
  • Troubleshoot solutions by using Application Insights

Implement caching for solutions

Expand

🧪 Lab 12: Enhance a web application by using the Azure Content Delivery Network ↗️

Configure cache and expiration policies for Azure Cache for Redis

Implement secure and optimized application cache patterns including data sizing, connections, encryption, and expiration

Implement Azure Content Delivery Network (Azure CDN) endpoints and profiles

Troubleshoot solutions by using Application Insights

Configure an app or service to use Application Insights

Monitor and analyze metrics, logs, and traces

Implement Application Insights web tests and alerts

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