General

Hello everyone! In today’s blog post, we look into the deployment of our Azure infrastructure and some post-configuration steps.

We use GitHub Actions to deploy our infrastructure.

In the repository, there are two workflow files: one to deploy the infrastructure and one to tear it down.

We will go over some of the elements inside the deploy.yaml workflow.

GitHub Actions

Prerequisites to connect to Azure

permissions:
  id-token: write
  contents: read
  

Connect to Azure and set subscription

- name: Azure Login
  uses: Azure/login@v1
  with:
    client-id: ${{ secrets.AZURE_CLIENT_ID }}
    tenant-id: ${{ secrets.AZURE_TENANT_ID }}
    subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

Deploy template

  • Before we deploy the template, we first lint and then validate it
- name: Validate template
  working-directory: ${{ github.workspace }}/bicep
  run: |
    az deployment sub validate \
      --name "$DEPLOYMENT_NAME" \
      --location westeurope \
      --template-file main.bicep \
      --parameters "main.parameters.json" \
                    subscription_id="$SUBSCRIPTION_ID" \
                    mysql_admin_password="$ADMIN_PASSWORD" \
                    jumpbox_admin_password="$ADMIN_PASSWORD" \
                    github_runner_object_id="${{ secrets.AZURE_CLIENT_ID }}"

Post-configuration steps

Download database certificate in Kudo environment

cd /home/site/wwwroot && mkdir bin && cd bin
curl <https://cacerts.digicert.com/DigiCertGlobalRootCA.crt.pem> -o DigiCertGlobalRootCA.crt.pem

kudu-environment

Import WordPress image to Azure Container Registry

  • Allow your IP from the Key Vault’s firewall and give yourself permission to get and list secrets through access policies

  • Login to the jumpbox through Bastion using the credentials stored in the Key Vault

bastion-login

  • Run the following:
az login --identity
cr_name="{your_registry_name}"
az acr import -n $cr_name --source docker.io/library/wordpress:latest --image wordpress:latest
az acr repository list -n $cr_name

Install WordPress

Summary

So we deployed our infrastructure and completed the essential post-configuration tasks. In the following and final post, we will configure monitoring and run some tests on our WordPress website.

Next part:

Previous parts:

Related repository: WordPress-on-Azure

Leave a comment