Skip to content

Latest commit

 

History

History
190 lines (134 loc) · 4.12 KB

cd_github_actions.md

File metadata and controls

190 lines (134 loc) · 4.12 KB
title author
Deploy applications to Azure using GitHub Actions
Part 3 of 3 in the [Build end-to-end CI/CD capabilities directly in GitHub](https://github.com/MSUSDEV/end-to-end-github-actions) series

Deploy applications to Azure using GitHub Actions

Overview

About us

Presenter Name

☁️ Presenter Title

For questions or help with this series: [email protected]

All demos and source code available online:

https://github.com/msusdev/end-to-end-github-actions

Setting the scene

Series roadmap

  • Session 1:
    • Introduction to GitHub Actions
  • Session 2:
    • Continuous integration using GitHub Actions
  • Session 3:
    • ↪️ Deploy applications to Azure using GitHub Actions

Agenda

  1. Set-up Azure service principal and credentials
  2. Deploy Azure Container Instance using ARM template
  3. Deploy to App Service using compressed folder
  4. Deploy to App Service directly

Time to deploy to Azure from GitHub Actions

Demo: Automating Azure Deployment

::: notes

Set-up Azure login

  1. Get service principal

    az ad sp create-for-rbac --name ghasp --role contributor --scopes /subscriptions/<subscription-id> --sdk-auth
  2. Add result JSON object as a GitHub secret named AZURE_CREDENTIALS

  3. Add subscription ID as a GitHub secret name AZURE_SUBSCRIPTION_ID

  4. Add new job

    deploy-azure-containers:
      name: Deploy containers to Azure
      runs-on: ubuntu-latest
      needs: build-container
      steps:
  5. Login to Azure

    - name: Login to Azure
      uses: azure/login@v1
      with:
        creds: ${{ secrets.AZURE_CREDENTIALS }}

Deploy ACI to resource group

  1. Checkout code

    - name: Checkout code
      uses: actions/checkout@v2
  2. Add ARM template to project (https://gist.github.com/seesharprun/63ad396f4855aee5130557ab59159d1c)

  3. Add ARM deployment step

    - name: Deploy ACI instance
      uses: azure/arm-deploy@v1
      with:
        subscriptionId: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
        resourcegroupName: Production
        template: azuredeploy.json

Deploy to Azure Web App container

  1. Deploy Web App in the Azure portal

  2. Create an environment variable for the web app's name

    env:
      WEB_APP_NAME: <web-app-name-here>
  3. Add Web App container deployment step

    - name: Deploy Web App container
      uses: azure/webapps-deploy@v2
      with:
        app-name: ${{ env.WEB_APP_NAME }}
        images: msusdev/webnext

Deploy to Azure Web App using code

  1. Add another new job

    deploy-azure-manual:
      name: Deploy code directly to Azure
      runs-on: ubuntu-latest
      needs: build-project
      steps:
  2. Create an environment variable for the web app's name

    env:
      WEB_APP_NAME: <web-app-name-here>
  3. Download artifact

    - name: Download site content
      uses: actions/download-artifact@v2
      with:
        name: site-build
  4. Login to Azure

    - name: Login to Azure
      uses: azure/login@v1
      with:
        creds: ${{ secrets.AZURE_CREDENTIALS }}
  5. Deploy code to App Service

    - name: Deploy Web App code
      uses: azure/webapps-deploy@v2
      with:
        app-name: ${{ env.WEB_APP_NAME }}
        package: .

Deploy to Azure Static Web Apps using alt workflow

  1. Create an Azrue Static Web App using the portal

:::

Review

Agenda (revisted)

  1. Set-up Azure service principal and credentials
  2. Deploy Azure Container Instance using ARM template
  3. Deploy to App Service using compressed folder
  4. Deploy to App Service directly

Links