Build, test, and deploy containers to Azure Kubernetes Service (AKS) using GitHub Actions
Article
GitHub Actions gives you the flexibility to build an automated software development lifecycle workflow. You can use multiple Kubernetes actions to deploy to containers from Azure Container Registry (ACR) to Azure Kubernetes Service (AKS) with GitHub Actions.
When using GitHub Actions, you need to configure the integration between Azure and your GitHub repository. To configure the integration, see Use GitHub Actions to connect to Azure.
As an example, you can use GitHub Actions to deploy an application to your AKS cluster every time a change is pushed to your GitHub repository. This example uses the Azure Vote application.
Note
This example uses a service principal for authentication with your ACR and AKS cluster. Alternatively, you can configure Open ID Connect (OIDC) and update the azure/login action to use OIDC. For more information, see Set up Azure Login with OpenID Connect authentication.
Fork and update the repository
Navigate to the Azure Vote repository and select Fork.
Update the azure-vote-all-in-one-redis.yaml to use your ACR for the azure-vote-front image. Replace <registryName> with the name of your registry.
Commit the updated azure-vote-all-in-one-redis.yaml to your repository.
Create secrets
Create a service principal to access your resource group with the Contributor role using the az ad sp create-for-rbac command. Replace <SUBSCRIPTION_ID> with the subscription ID of your Azure account and <RESOURCE_GROUP> with the name of the resource group containing your ACR.
az ad sp create-for-rbac \
--name "ghActionAzureVote" \
--scope /subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP> \
--role Contributor \
--json-auth
Your output should look similar to the following example output:
The on section contains the event that triggers the action. In the example file, the action triggers when a change is pushed to the azure-vote directory.
Commit the updated azure-vote/azure-vote/config_file.cfg to your repository.
In your repository, select Actions and confirm a workflow is running. Then, confirm the workflow has a green checkmark and the updated application is deployed to your cluster.
Next steps
Review the following starter workflows for AKS. For more information, see Using starter workflows.
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
Azure Kubernetes Service feedback
Azure Kubernetes Service is an open source project. Select a link to provide feedback:
Build end-to-end solutions in Microsoft Azure to create Azure Functions, implement and manage web apps, develop solutions utilizing Azure storage, and more.