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 |
Presenter Name
☁️ Presenter Title
For questions or help with this series: [email protected]
All demos and source code available online:
Session 1:Introduction to GitHub Actions
Session 2:Continuous integration using GitHub Actions
- Session 3:
- ↪️ Deploy applications to Azure using GitHub Actions
- Set-up Azure service principal and credentials
- Deploy Azure Container Instance using ARM template
- Deploy to App Service using compressed folder
- Deploy to App Service directly
::: notes
-
Get service principal
az ad sp create-for-rbac --name ghasp --role contributor --scopes /subscriptions/<subscription-id> --sdk-auth
-
Add result JSON object as a GitHub secret named AZURE_CREDENTIALS
-
Add subscription ID as a GitHub secret name AZURE_SUBSCRIPTION_ID
-
Add new job
deploy-azure-containers: name: Deploy containers to Azure runs-on: ubuntu-latest needs: build-container steps:
-
Login to Azure
- name: Login to Azure uses: azure/login@v1 with: creds: ${{ secrets.AZURE_CREDENTIALS }}
-
Checkout code
- name: Checkout code uses: actions/checkout@v2
-
Add ARM template to project (https://gist.github.com/seesharprun/63ad396f4855aee5130557ab59159d1c)
-
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 Web App in the Azure portal
-
Create an environment variable for the web app's name
env: WEB_APP_NAME: <web-app-name-here>
-
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
-
Add another new job
deploy-azure-manual: name: Deploy code directly to Azure runs-on: ubuntu-latest needs: build-project steps:
-
Create an environment variable for the web app's name
env: WEB_APP_NAME: <web-app-name-here>
-
Download artifact
- name: Download site content uses: actions/download-artifact@v2 with: name: site-build
-
Login to Azure
- name: Login to Azure uses: azure/login@v1 with: creds: ${{ secrets.AZURE_CREDENTIALS }}
-
Deploy code to App Service
- name: Deploy Web App code uses: azure/webapps-deploy@v2 with: app-name: ${{ env.WEB_APP_NAME }} package: .
- Create an Azrue Static Web App using the portal
:::
- Set-up Azure service principal and credentials
- Deploy Azure Container Instance using ARM template
- Deploy to App Service using compressed folder
- Deploy to App Service directly
- https://docs.microsoft.com/azure/app-service/deploy-container-github-action
- https://github.com/azure/actions-workflow-samples
- https://github.com/azure/login
- https://github.com/azure/arm-deploy
- https://github.com/azure/webapps-deploy
- https://gist.github.com/seesharprun/63ad396f4855aee5130557ab59159d1c
- https://gist.github.com/seesharprun/6e969f52a242a9c4681524df51b94ea4