Azure Container App is a fully managed Azure service that receives regular updates automatically. These updates are applied with minimal impact on the container applications. However, Azure Container App users can now define a maintenance window, allowing them to schedule service maintenance at a convenient time. This ensures application availability during important periods without downtime due to service maintenance.
There are two types of service updates, critical and non-critical updates. Critical updates are applied immediately when required, and users cannot set a maintenance window for them. However, maintenance windows can be set for non-critical updates. This blog explains how to set a maintenance window for Azure Container App using a GitHub Action pipeline.
The following is the Azure CLI command to set the maintenance window.
az containerapp env maintenance-config add --resource-group <RESOURCE_GROUP> --environment <ENVIRONMENT_NAME> --weekday Monday --start-hour-utc 1 --duration 8
We can create a GitHub Actions pipeline to set the maintenance window for the Container App environment, as shown in the YAML pipeline script below. Click here to view the full GitHub Actions pipeline.
- First, create an Azure SPN and add its values as a GitHub Actions secret with the name AZURE_CREDENTIALS as explained here.
- Then, run the following command using the Azure CLI task in the GitHub Actions pipeline, providing the resource group name, container app environment name, maintenance window day, start time, and duration.
example:
az containerapp env maintenance-config add --resource-group "demo-container-app" --environment "demo-container-app-env" --weekday Monday --start-hour-utc 1 --duration 8
name: Deploy Azure VM
on:
push:
branches:
- main
workflow_dispatch:
jobs:
deploy-vm:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Azure Login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
allow-no-subscriptions: true
- name: Create Resource Group (if not exists)
run: |
az containerapp env maintenance-config add --resource-group "demo-container-app" --environment "demo-container-app-env" --weekday Monday --start-hour-utc 1 --duration 8
After running the pipeline, we can use the following command to get information about the currently active maintenance windows.
az containerapp env maintenance-config list --resource-group "demo-container-app" --environment "demo-container-app-env"
No comments:
Post a Comment