{"id":23427364,"url":"https://github.com/nhatthaiquang-agilityio/net6.webapi-aks-githubactions","last_synced_at":"2026-04-13T04:43:45.627Z","repository":{"id":43229310,"uuid":"509699086","full_name":"nhatthaiquang-agilityio/NET6.WebAPI-AKS-GitHubActions","owner":"nhatthaiquang-agilityio","description":".NET6 WebAPI sample and deploy with GitHub Actions ","archived":false,"fork":false,"pushed_at":"2022-10-27T08:35:09.000Z","size":385,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-09T12:29:35.616Z","etag":null,"topics":["azure","azure-kubernetes-service","docker","github-actions","helm","kubernetes","terraform","webapp"],"latest_commit_sha":null,"homepage":"","language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nhatthaiquang-agilityio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-07-02T08:20:00.000Z","updated_at":"2023-04-20T03:38:11.000Z","dependencies_parsed_at":"2023-01-20T02:35:22.140Z","dependency_job_id":null,"html_url":"https://github.com/nhatthaiquang-agilityio/NET6.WebAPI-AKS-GitHubActions","commit_stats":null,"previous_names":["nhatthaiquang-agilityio/net6.webapi-aks-githubactions"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nhatthaiquang-agilityio/NET6.WebAPI-AKS-GitHubActions","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nhatthaiquang-agilityio%2FNET6.WebAPI-AKS-GitHubActions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nhatthaiquang-agilityio%2FNET6.WebAPI-AKS-GitHubActions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nhatthaiquang-agilityio%2FNET6.WebAPI-AKS-GitHubActions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nhatthaiquang-agilityio%2FNET6.WebAPI-AKS-GitHubActions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nhatthaiquang-agilityio","download_url":"https://codeload.github.com/nhatthaiquang-agilityio/NET6.WebAPI-AKS-GitHubActions/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nhatthaiquang-agilityio%2FNET6.WebAPI-AKS-GitHubActions/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272214419,"owners_count":24893201,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-26T02:00:07.904Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["azure","azure-kubernetes-service","docker","github-actions","helm","kubernetes","terraform","webapp"],"created_at":"2024-12-23T06:20:11.604Z","updated_at":"2026-04-13T04:43:40.601Z","avatar_url":"https://github.com/nhatthaiquang-agilityio.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NET6.WebAPI\n.NET6 WebAPI sample using Github Actions for deployments to Azure Kubernetes Service\n\n### Github Runner Requirements\n------------------------------\n+ Install Docker \u0026 DockerCompose\n+ Minikube or Kubernetes cluster (see below if needed)\n+ Install azure cli\n+ Install Kubectl\n\n## Usage\n---------\n### Setup Azure\n----------------\n+ Azure Login\n    ```\n    az login\n    ```\n\n+ Create group in Azure\n    ```\n    az group create --name LearningDeployment --location KoreaCentral\n    ```\n\n+ Create AKS Cluster\n    ```\n    az aks create --resource-group LearningDeployment --name AKSLearningGithubActions --node-count 2 --generate-ssh-keys\n    ```\n\n+ Get Credentials for kubectl\n    ```\n    az aks get-credentials -n AKSLearningGithubActions -g LearningDeployment\n    ```\n\n+ Create ACR\n    ```\n    az acr create --resource-group LearningDeployment --name learndeploymentgithub --sku Basic\n    ```\n\n+ Login ACR(Required: docker start on your machine)\n    ```\n    az acr login --name learndeploymentgithub\n    ```\n\n+ Create AZURE_CREDENTIALS\n    ```\n    az ad sp create-for-rbac --name \"net6web\" --role contributor --scopes /subscriptions/\u003cSUBSCRIPTION_ID\u003e/resourceGroups/\u003cRESOURCE_GROUP\u003e --sdk-auth\n    ```\n    Copy and paste into secret AZURE_CREDENTTIAL in the github repository\n\n\n+ [Create container registry Credentials](https://docs.microsoft.com/en-us/azure/container-registry/container-registry-auth-service-principal)\n    ```\n    #!/bin/bash\n    # This script requires Azure CLI version 2.25.0 or later. Check version with `az --version`.\n\n    # Modify for your environment.\n    # ACR_NAME: The name of your Azure Container Registry\n    # SERVICE_PRINCIPAL_NAME: Must be unique within your AD tenant\n    ACR_NAME=learndeploymentgithub\n    SERVICE_PRINCIPAL_NAME=PrincipalLearnDeploymentGithubActions\n\n    # Obtain the full registry ID\n    ACR_REGISTRY_ID=$(az acr show --name $ACR_NAME --query \"id\" --output tsv)\n    # echo $registryId\n\n    # Create the service principal with rights scoped to the registry.\n    # Default permissions are for docker pull access. Modify the '--role'\n    # argument value as desired:\n    # acrpull:     pull only\n    # acrpush:     push and pull\n    # owner:       push, pull, and assign roles\n    PASSWORD=$(az ad sp create-for-rbac --name $SERVICE_PRINCIPAL_NAME --scopes $ACR_REGISTRY_ID --role acrpush --query \"password\" --output tsv)\n    USER_NAME=$(az ad sp list --display-name $SERVICE_PRINCIPAL_NAME --query \"[].appId\" --output tsv)\n\n    # Output the service principal's credentials; use these in your services and\n    # applications to authenticate to the container registry.\n    echo \"Service principal ID: $USER_NAME\"\n    echo \"Service principal password: $PASSWORD\"\n    ```\n\n+ Run Github Action deploy_aks\n\n### Using Terraform in AKZ\n---------------------------\n+ Azure Login\n    ```\n    az login\n    ```\n\n+ Set up the privileges for accessing the Azure resources required for using Terraform\n    ```\n    az ad sp create-for-rbac --name \"net6web\" --role contributor --scopes /subscriptions/\u003cSUBSCRIPTION_ID\u003e\n    ```\n    Copy and paste appId and password into terraform.tfvar\n\n\n+ Create AZURE_CREDENTIALS\n    ```\n    az ad sp create-for-rbac --name \"net6web\" --role contributor --scopes /subscriptions/\u003cSUBSCRIPTION_ID\u003e/resourceGroups/\u003cRESOURCE_GROUP\u003e --sdk-auth\n    ```\n    Copy and paste into secret AZURE_CREDENTTIAL in the github repository\n\n+ Get Credentials for kubectl\n    ```\n    az aks get-credentials -n AKSLearningGithubActions -g LearningDeployment\n    ```\n+ [Create container registry Credentials](https://docs.microsoft.com/en-us/azure/container-registry/container-registry-auth-service-principal)\n    ```\n    #!/bin/bash\n    # This script requires Azure CLI version 2.25.0 or later. Check version with `az --version`.\n\n    # Modify for your environment.\n    # ACR_NAME: The name of your Azure Container Registry\n    # SERVICE_PRINCIPAL_NAME: Must be unique within your AD tenant\n    ACR_NAME=learndeploymentgithub\n    SERVICE_PRINCIPAL_NAME=PrincipalLearnDeploymentGithubActions\n\n    # Obtain the full registry ID\n    ACR_REGISTRY_ID=$(az acr show --name $ACR_NAME --query \"id\" --output tsv)\n    # echo $registryId\n\n    # Create the service principal with rights scoped to the registry.\n    # Default permissions are for docker pull access. Modify the '--role'\n    # argument value as desired:\n    # acrpull:     pull only\n    # acrpush:     push and pull\n    # owner:       push, pull, and assign roles\n    PASSWORD=$(az ad sp create-for-rbac --name $SERVICE_PRINCIPAL_NAME --scopes $ACR_REGISTRY_ID --role acrpush --query \"password\" --output tsv)\n    USER_NAME=$(az ad sp list --display-name $SERVICE_PRINCIPAL_NAME --query \"[].appId\" --output tsv)\n\n    # Output the service principal's credentials; use these in your services and\n    # applications to authenticate to the container registry.\n    echo \"Service principal ID: $USER_NAME\"\n    echo \"Service principal password: $PASSWORD\"\n    ```\n\n    Copy paste REGISTRY_USERNAME\u0026REGISTRY_PASSWORD of github secret\n\n### Create Ingress and expose IP\n---------------------------------\n+ Create Static IP\n    ```\n    az aks show --resource-group LearningDeployment --name AKSLearningGithubActions --query nodeResourceGroup -o tsv\n    ```\n    --\u003e MC_LearningDeployment_AKSLearningGithubActions_koreacentral\n\n\n    ```\n    az network public-ip create --resource-group MC_LearningDeployment_AKSLearningGithubActions_koreacentral --name AKSLearningGithubActions --sku Standard --allocation-method static --query publicIp.ipAddress -o tsv\n    ```\n    --\u003e 20.249.96.38(IP Address)\n\n+ Create namespace for ingress\n    ```\n    kubectl create namespace ingress-basic\n    ```\n\n+ Add ingress-nginx repo from helm command\n    ```\n    helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx\n    helm repo add stable https://kubernetes-charts.storage.googleapis.com/\n    helm repo update\n    ```\n\n+ Set Ingress with IP(expose IP)\n    ```\n    helm install ingress-nginx ingress-nginx/ingress-nginx --namespace ingress-basic --set controller.replicaCount=2 --set controller.nodeSelector.\"beta\\.kubernetes\\.io/os\"=linux --set defaultBackend.nodeSelector.\"beta\\.kubernetes\\.io/os\"=linux --set controller.service.externalTrafficPolicy=Local --set controller.service.loadBalancerIP=\"20.249.96.38\"\n    ```\n\n+ Check service\n    ```\n    kubectl get service -l app.kubernetes.io/name=ingress-nginx --namespace ingress-basic\n    ```\n    Results:\n    ```\n    ingress-nginx-controller             LoadBalancer   10.0.42.164   20.249.96.38   80:31350/TCP,443:30212/TCP   68s\n    ingress-nginx-controller-admission   ClusterIP      10.0.69.59    \u003cnone\u003e         443/TCP                      68s\n    ```\n\n+ Get external IP\n    ```\n    kubectl get all -n ingress-basic\n    ```\n    --\u003e Go to browser and enter IP(http://20.249.96.38/). It should be showed nginx(404 NOT FOUND)\n\n+ Check the Web APP\n    ```\n    http://20.249.96.38/webapi\n    ```\n\n### Result\n![Azure Kubernetes Sevice](./images/AKS.png)\n![Web site](./images/Web.png)\n\n### References\n---------------\n+ [Install Azure CLI](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-macos)\n+ [AKS Github Actions](https://docs.microsoft.com/en-us/azure/aks/kubernetes-action?tabs=userlevel)\n+ [KubeLab Github Actions](https://azure.github.io/kube-labs/1-github-actions.html#_1-create-a-deployment-pipeline)\n+ [AKS deployment with github actions](https://docs.microsoft.com/en-us/learn/modules/aks-deployment-pipeline-github-actions/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnhatthaiquang-agilityio%2Fnet6.webapi-aks-githubactions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnhatthaiquang-agilityio%2Fnet6.webapi-aks-githubactions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnhatthaiquang-agilityio%2Fnet6.webapi-aks-githubactions/lists"}