Using GitHub Actions to Deploy Your
Workloads to Azure
Kasun Kodagoda
Technical Lead | 99X Technology
https://kasunkodagoda.com
♥
I am, Kasun Kodagoda
• In ♥ with Azure & Azure DevOps
• Active Blogger – https://kasunkodagoda.com
• Open Source Contributor - https://github.com/kasunkv
• Technical Lead
I Work For,
• Established in 2004
• Headquartered in Sri Lanka with offices in
Europe and Australia
• Providing high quality, high value Software
Product Engineering + R&D services
Agenda
• Basics of GitHub Actions
• Core Concepts
• GitHub Actions for Azure
• Demo
What are GitHub Actions
• Made up of individual tasks called Actions
• Collection of actions performs a certain
activity
• This collection is called a workflow
These Workflows helps you automate your software
development activities in the same place where you store
your source code
Core Concepts
Action
• Smallest building block of a workflow
• Individual task that performs a specific
activity in a workflow
• Two Types of Actions
• JavaScript Actions
- Hosted on a public repository
• Docker Actions
- Hosted on a public docker registry
Artifacts
• Output of a workflow
• Can include,
• A set of files (e.g. files of a web app)
• Test results
• Log files
• Screenshots etc.
• Can be shared with other jobs or be
deployed
Event
• Activity that can trigger a workflow run
• An event can have multiple activity types
• Could be any GitHub event
• push
• pull_request
• create
• delete
• issue_comment
• created
• edited
• deleted
https://help.github.com/en/actions/reference/events-that-trigger-workflows
Job
• Set of steps that gets executed on the
same runner.
• In a single workflow, there can be multiple
jobs
• Can have dependencies between jobs in a
workflow file
- job_1
- job_2
- job_3
job_2 can depend on job_1. job_3 can depend on jod_2
Job Strategy
• Creates a build matrix for the jobs
• Define different variations of the
environment
• Run the job on build matrix at the same
time.
strategy:
matrix:
node: [6, 8, 10]
steps:
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
Workflow
• Configurable automated process
• Contained in the repository
• In .github/workflows directory
• Made up of one or more jobs
• Triggered by an event or a schedule
• Described in a YAML file
• Must contain at least one job
Workflow Run
• Instance of a workflow
• Runs when the trigger event occurs
• E.g. pull_request, push
• You can see;
• Execution logs
• Status and results
• Artifacts
Runners
• GitHub hosted virtual environments that
run workflows
• All 3 major OS platforms are supported
• Windows
- Runs Windows Server 2019
- windows-latest or windows-2019
• Linux
- Runs Ubuntu 16.04 and 18.04
- ubuntu-latest or ubuntu-18.04 and ubuntu-16.04
• MacOS
- Runs MacOS Catalina 10.15
- macos-latest or macos-10.15
Runners – ctd.
• Two types of runners available
• GitHub Hosted
• Automatically updated
• Managed and maintained by GitHub
• Clean instance for every job execution
• Free minutes/rates will be applied depending on the plan
• Self-Hosted
• Local or any cloud infrastructure you own
• You pay for your own infrastructure
• You can customize with hardware, software & tools you want
• No need to have a clean instance for each job execution
• No rates are applied, free to you.
• You need to maintain your environments
Runners – ctd.
• Linux and Windows VMs are hosted in
Azure
• Standard_DS2_v2 sku
• Based on the Azure Pipelines Agent
• MacOS VMs are hosted in MacStadium
https://help.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners
Usage Limits
• Job Execution Time
• GitHub Hosted – 6 hrs
• Self-Hosted – Unlimited
• Workflow Run Time
• GitHub Hosted, Self-Hosted – 72 hrs
• Job Queue Time
• GitHub Hosted – Not Applicable
• Self-Hosted – 24 hrs
• Job Matrix
• GitHub Hosted, Self Hosted – Max. 256 Jobs per
workflow
Usage Limits – ctd.
• API Requests
• 1000 Requests per Hour
• Across all actions for a single repository
• Both GitHub Hosted and Self-Hosted.
• Concurrent Jobs
Plan Total Concurrent Jobs Max. Concurrent macOS Jobs
Free 20 5
Pro 40 5
Team 60 5
Enterprise 180 50
GitHub Marketplace
• Central location to find GitHub Actions
• Created by official organizations and the
community
• Accessible through the workflow editor
GitHub Actions for Azure
GitHub Actions for Azure
• Set of actions to access Azure Services
• Azure cloud resources
• Azure Pipelines builds and releases
• Deploy workloads to Azure cloud from
workflows
• Some of the widely used Azure services
are accessible
• More on the way
Connecting to Azure
• Azure Login
• azure/login
• Authenticate to Azure using a service principle
• Azure CLI
• azure/cli
• Configures the runner with the latest or specified version
of the Azure CLI
• Run Azure CLI scripts to manage Azure Resources
Azure Web Apps
• Azure Web App
• azure/webapps-deploy
• Deploy your web site artifacts to Azure Web Apps
• Azure Web App for Containers
• azure/webapps-container-deploy
• Deploy your web app, packaged as a container to Azure
Web Apps.
• Azure App Service Settings
• azure/appservice-settings
• Configure App Settings and Connection string on Azure
App Service .
Azure Function Apps
• Azure Functions
• azure/functions-action
• Deploy your serverless code to an Azure Function App
• Azure Functions for Containers
• azure/functions-container-action
• Deploy your custom container image to Azure Functions
App.
Azure Kubernetes Services
• Kubectl Tools Installer
• azure/setup-kubectl
• Installs specific version of kubectl on the runner
• AKS Set Context
• azure/aks-set-context
• Set the Kubernetes cluster context on AKS
• Kubernetes Deploy
• azure/k8s-deploy
• Deploy manifests to the Kubernetes cluster
Azure Kubernetes Services – ctd.
• Setup Help
• azure/setup-helm
• Installs specific version of Helm on the runner
• Kubernetes Create Secret
• azure/k8s-create-secret
• Create secret on Kubernetes cluster
• More Actions…
• https://github.com/Azure/actions#deploy-to-
kubernetes
Azure Databases
• Azure SQL Databse
• azure/sql-action
• Deploy DACPAC and SQL Scripts to Azure SQL Database
• Uses a connection string to authenticate
• Azure MySQL Database
• azure/mysql-action
• Deploy MySQL databases using SQL Scripts
• Uses a connection string to authenticate
Few More…
• Azure Pipelines
• azure/pipelines
• Trigger Azure Pipeline run as part of the workflow
• Docker Login
• azure/docker-login
• Push containers to Docker Hub or Azure Container
Registry
• Get Secret from Azure Key Vault
• azure/get-keyvault-secret
• Fetch one or more Key Vault secrets.
https://github.com/Azure/actions
Let’s See it in Action
Thank You :)
Any Questions? ;)
Sample Code
https://github.com/kasunkv/
Slide Deck
https://www.slideshare.net/KasunKodagoda1
Blog Posts
https://kasunkodagoda.com/tag/azure/
Connect With Me
Twitter: https://twitter.com/kasun_kodagoda
Facebook: https://www.facebook.com/kasun.kodagoda
LinkedIn: https://www.linkedin.com/in/kasunkodagoda/
Blog: https://kasunkodagoda.com/
http://bit.ly/github-actions-sl-devops-community

Using GitHub Actions to Deploy your Workloads to Azure

  • 1.
    Using GitHub Actionsto Deploy Your Workloads to Azure Kasun Kodagoda Technical Lead | 99X Technology https://kasunkodagoda.com ♥
  • 2.
    I am, KasunKodagoda • In ♥ with Azure & Azure DevOps • Active Blogger – https://kasunkodagoda.com • Open Source Contributor - https://github.com/kasunkv • Technical Lead I Work For, • Established in 2004 • Headquartered in Sri Lanka with offices in Europe and Australia • Providing high quality, high value Software Product Engineering + R&D services
  • 3.
    Agenda • Basics ofGitHub Actions • Core Concepts • GitHub Actions for Azure • Demo
  • 4.
    What are GitHubActions • Made up of individual tasks called Actions • Collection of actions performs a certain activity • This collection is called a workflow These Workflows helps you automate your software development activities in the same place where you store your source code
  • 5.
  • 6.
    Action • Smallest buildingblock of a workflow • Individual task that performs a specific activity in a workflow • Two Types of Actions • JavaScript Actions - Hosted on a public repository • Docker Actions - Hosted on a public docker registry
  • 7.
    Artifacts • Output ofa workflow • Can include, • A set of files (e.g. files of a web app) • Test results • Log files • Screenshots etc. • Can be shared with other jobs or be deployed
  • 8.
    Event • Activity thatcan trigger a workflow run • An event can have multiple activity types • Could be any GitHub event • push • pull_request • create • delete • issue_comment • created • edited • deleted https://help.github.com/en/actions/reference/events-that-trigger-workflows
  • 9.
    Job • Set ofsteps that gets executed on the same runner. • In a single workflow, there can be multiple jobs • Can have dependencies between jobs in a workflow file - job_1 - job_2 - job_3 job_2 can depend on job_1. job_3 can depend on jod_2
  • 10.
    Job Strategy • Createsa build matrix for the jobs • Define different variations of the environment • Run the job on build matrix at the same time. strategy: matrix: node: [6, 8, 10] steps: - uses: actions/setup-node@v1 with: node-version: ${{ matrix.node }}
  • 11.
    Workflow • Configurable automatedprocess • Contained in the repository • In .github/workflows directory • Made up of one or more jobs • Triggered by an event or a schedule • Described in a YAML file • Must contain at least one job
  • 12.
    Workflow Run • Instanceof a workflow • Runs when the trigger event occurs • E.g. pull_request, push • You can see; • Execution logs • Status and results • Artifacts
  • 13.
    Runners • GitHub hostedvirtual environments that run workflows • All 3 major OS platforms are supported • Windows - Runs Windows Server 2019 - windows-latest or windows-2019 • Linux - Runs Ubuntu 16.04 and 18.04 - ubuntu-latest or ubuntu-18.04 and ubuntu-16.04 • MacOS - Runs MacOS Catalina 10.15 - macos-latest or macos-10.15
  • 14.
    Runners – ctd. •Two types of runners available • GitHub Hosted • Automatically updated • Managed and maintained by GitHub • Clean instance for every job execution • Free minutes/rates will be applied depending on the plan • Self-Hosted • Local or any cloud infrastructure you own • You pay for your own infrastructure • You can customize with hardware, software & tools you want • No need to have a clean instance for each job execution • No rates are applied, free to you. • You need to maintain your environments
  • 15.
    Runners – ctd. •Linux and Windows VMs are hosted in Azure • Standard_DS2_v2 sku • Based on the Azure Pipelines Agent • MacOS VMs are hosted in MacStadium https://help.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners
  • 16.
    Usage Limits • JobExecution Time • GitHub Hosted – 6 hrs • Self-Hosted – Unlimited • Workflow Run Time • GitHub Hosted, Self-Hosted – 72 hrs • Job Queue Time • GitHub Hosted – Not Applicable • Self-Hosted – 24 hrs • Job Matrix • GitHub Hosted, Self Hosted – Max. 256 Jobs per workflow
  • 17.
    Usage Limits –ctd. • API Requests • 1000 Requests per Hour • Across all actions for a single repository • Both GitHub Hosted and Self-Hosted. • Concurrent Jobs Plan Total Concurrent Jobs Max. Concurrent macOS Jobs Free 20 5 Pro 40 5 Team 60 5 Enterprise 180 50
  • 18.
    GitHub Marketplace • Centrallocation to find GitHub Actions • Created by official organizations and the community • Accessible through the workflow editor
  • 19.
  • 20.
    GitHub Actions forAzure • Set of actions to access Azure Services • Azure cloud resources • Azure Pipelines builds and releases • Deploy workloads to Azure cloud from workflows • Some of the widely used Azure services are accessible • More on the way
  • 21.
    Connecting to Azure •Azure Login • azure/login • Authenticate to Azure using a service principle • Azure CLI • azure/cli • Configures the runner with the latest or specified version of the Azure CLI • Run Azure CLI scripts to manage Azure Resources
  • 22.
    Azure Web Apps •Azure Web App • azure/webapps-deploy • Deploy your web site artifacts to Azure Web Apps • Azure Web App for Containers • azure/webapps-container-deploy • Deploy your web app, packaged as a container to Azure Web Apps. • Azure App Service Settings • azure/appservice-settings • Configure App Settings and Connection string on Azure App Service .
  • 23.
    Azure Function Apps •Azure Functions • azure/functions-action • Deploy your serverless code to an Azure Function App • Azure Functions for Containers • azure/functions-container-action • Deploy your custom container image to Azure Functions App.
  • 24.
    Azure Kubernetes Services •Kubectl Tools Installer • azure/setup-kubectl • Installs specific version of kubectl on the runner • AKS Set Context • azure/aks-set-context • Set the Kubernetes cluster context on AKS • Kubernetes Deploy • azure/k8s-deploy • Deploy manifests to the Kubernetes cluster
  • 25.
    Azure Kubernetes Services– ctd. • Setup Help • azure/setup-helm • Installs specific version of Helm on the runner • Kubernetes Create Secret • azure/k8s-create-secret • Create secret on Kubernetes cluster • More Actions… • https://github.com/Azure/actions#deploy-to- kubernetes
  • 26.
    Azure Databases • AzureSQL Databse • azure/sql-action • Deploy DACPAC and SQL Scripts to Azure SQL Database • Uses a connection string to authenticate • Azure MySQL Database • azure/mysql-action • Deploy MySQL databases using SQL Scripts • Uses a connection string to authenticate
  • 27.
    Few More… • AzurePipelines • azure/pipelines • Trigger Azure Pipeline run as part of the workflow • Docker Login • azure/docker-login • Push containers to Docker Hub or Azure Container Registry • Get Secret from Azure Key Vault • azure/get-keyvault-secret • Fetch one or more Key Vault secrets. https://github.com/Azure/actions
  • 28.
    Let’s See itin Action
  • 29.
    Thank You :) AnyQuestions? ;)
  • 30.
    Sample Code https://github.com/kasunkv/ Slide Deck https://www.slideshare.net/KasunKodagoda1 BlogPosts https://kasunkodagoda.com/tag/azure/ Connect With Me Twitter: https://twitter.com/kasun_kodagoda Facebook: https://www.facebook.com/kasun.kodagoda LinkedIn: https://www.linkedin.com/in/kasunkodagoda/ Blog: https://kasunkodagoda.com/ http://bit.ly/github-actions-sl-devops-community