Home Arrow Icon Knowledge base Arrow Icon Global Arrow Icon How do I connect my GitHub repository to Azure for deployment


How do I connect my GitHub repository to Azure for deployment


To connect your GitHub repository to Azure for deployment, follow these steps:

Step 1: Create an Azure App Service

1. Go to the Azure portal and navigate to the App Service section.
2. Click Create a resource and select Web App.
3. Fill in the required details and click Review + Create.

Step 2: Configure Deployment Center

1. Navigate to the newly deployed app service resource and choose Deployment Center from the left panel.
2. Click GitHub and press Continue.
3. Authorize your GitHub account and select the repository you want to connect.
4. Choose the branch you want to deploy from and the build provider as App Service Build Service.
5. Click Finish to complete the setup.

Step 3: Configure GitHub Actions

1. Create a new file named `.github/workflows/azure-deploy.yml` in your repository.
2. Define the workflow using YAML syntax:

yaml
   name: Azure Deploy
   on:
     push:
       branches:
         - main
   jobs:
     deploy:
       runs-on: ubuntu-latest
       steps:
         - name: Checkout code
           uses: actions/checkout@v2
         - name: Login to Azure
           uses: azure/login@v1
           with:
             creds: ${{ secrets.AZURE_CREDENTIALS }}
         - name: Deploy to Azure
           uses: azure/app-service@v1
           with:
             app-name: <app-name>
             resource-group: <resource-group>
             plan: <plan>
             deployment-slot: <deployment-slot>
   

Step 4: Configure Azure Credentials

1. Create a new secret in your GitHub repository settings:

bash
   name: AZURE_CREDENTIALS
   value: <azure-credentials>
   

Step 5: Trigger the Workflow

1. Push changes to the `main` branch to trigger the workflow.

By following these steps, you can connect your GitHub repository to Azure for deployment.

Citations:
[1] https://dev.to/parveensingh/continuous-deployment-for-azure-app-service-github-and-azure-repos-4oog
[2] https://learn.microsoft.com/en-us/azure/developer/github/deploy-to-azure
[3] https://docs.github.com/en/actions/deployment/deploying-to-your-cloud-provider/deploying-to-azure/deploying-net-to-azure-app-service
[4] https://circleci.com/blog/continuous-deployment-for-azure-web-apps/
[5] https://docs.github.com/en/actions/deployment/deploying-to-your-cloud-provider/deploying-to-azure