Web App with Github Actions

Open Azure Portal → App Services → Create Web App

1- Basics

Untitled

2- Deployment

Untitled

AZURE FUNCTIONS FOR WEB DEPLOYMENT

Using Azure Portal

Untitled

Using VSCode Azure Extension (Recommended)

1- Install Azure extension on VSCode.

2- Then create function app. (Select advanced. Create everything for app as new and make plan as premium Elastic Premium (EP1: 1)) Linux. (Don’t use consumption plan) You can skip application insight creation.

3- From Function App’s deployment center part in Azure, connect to github repository for continious deployment.

5- Open Azure Portal -> Your Function App -> Overview -> Get Publish Profile and download.

6- Open Settings→Secrets of Github Repo and paste all content of downloaded file to it. Use AZURE_FUNCTION_PUBLISH_PROFILE name and put the same name in yml’s Azure/functions-action@v1 Deploy to Azure Functions section.

7- Select “Deploy to Function App” from cloud button as in right image.

Untitled

3- Workflow Configuration File

# Docs for the Azure Web Apps Deploy action: <https://github.com/Azure/webapps-deploy>
# More GitHub Actions for Azure: <https://github.com/Azure/actions>
# More info on Python, GitHub Actions, and Azure App Service: <https://aka.ms/python-webapps-actions>

name: Build and deploy Python app to Azure Web App - age-prediction

on:
  push:
    branches:
      - master
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - name: Set up Python version
        uses: actions/setup-python@v1
        with:
          python-version: '3.8'

      - name: Create and start virtual environment
        run: |
          python -m venv venv
          source venv/bin/activate
      
      - name: Install dependencies
        run: pip install -r requirements.txt
        
      # Optional: Add step to run tests here (PyTest, Django test suites, etc.)
      
		  # Artifacts are model files in Azure ML Studio.
      - name: Upload artifact for deployment jobs
        uses: actions/upload-artifact@v2
        with:
          name: python-app
          path: |
            . 
            !venv/

  deploy:
    runs-on: ubuntu-latest
    needs: build
    environment:
      name: 'production'
      url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

    steps:
      - name: Download artifact from build job
        uses: actions/download-artifact@v2
        with:
          name: python-app
          path: .
          
      - name: 'Deploy to Azure Web App'
        uses: azure/webapps-deploy@v2
        id: deploy-to-webapp
        with:
          app-name: 'age-prediction'
          slot-name: 'production'
          publish-profile: ${{ secrets.AzureAppService_PublishProfile_1234 }}
### To access files in Azure Storage
- name: 'Deploy model to Azure Web App'
    uses: azure/webapps-deploy@v2
    with:
      app-name: 'age-prediction'
  slot-name: 'Production'
  publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_229FDF161AA347DB981BBE9BC915A41A }}
  local-artifact: true
  artifact-name: 'age_model_b/age_model_abhipsrajsahoo2.h5'
  artifact-type: 'folder'
  artifact-link: '<https://sgmlworkstorageef1c6630d.blob.core.windows.net/azureml-blobstore-825cc236-ef0c-4097-a4c3-c66b60e48acf/WebUpload/221208203447-1128685028/age_model_b>'
  #artifact-link: 'https://<storage-account-name>.blob.core.windows.net/<container-name>/<model-folder>'

If you get error in deployment step;

Redeploy and set “Always on” option to false.

If that doesn’t resolve your issue, https://<web-page-name>scm.azurewebsites.net/DebugConsole open this to access to Kudu debug console for more detail.


Untitled