Giter VIP home page Giter VIP logo

Comments (5)

joeystdio avatar joeystdio commented on August 14, 2024 6

Here is a working example for you my friend. Just setup the publish profile as a secret and your done.
(and of course change the variables)
And also notice the folder "Triggered". If you have a continuous job change that folder to "Continuous".

name: Deploy WebJob

on:
  workflow_dispatch:

  push:
    branches: [ develop ]

env:
  WEBJOB_NAME: YourWebJobName
  AZURE_APP_NAME: your-azure-app-service-name
  PROJECT_ROOT: path/to/your/Project.Root
  TEST_PROJECT_ROOT: path/to/your/Project.Root.Tests
  DOTNET_VERSION: '3.1.x'

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    # Checkout the repo
    - uses: actions/checkout@v2

    # Setup .NET Core SDK
    - name: Setup .NET Core
      uses: actions/setup-dotnet@v1
      with:
        dotnet-version: ${{ env.DOTNET_VERSION }}
    
    - name: dotnet test
      run: |
        dotnet test ${{ env.TEST_PROJECT_ROOT }}

    - name: dotnet publish
      run: |
        dotnet publish -c Release -o './publish/App_Data/Jobs/Triggered/${{ env.WEBJOB_NAME }}' ${{ env.PROJECT_ROOT }}

    - name: Deploy to Azure App Service
      uses: azure/webapps-deploy@v2
      with: 
        app-name: ${{ env.AZURE_APP_NAME }}
        publish-profile: ${{ secrets.PUBLISH_PROFILE }}
        package: './publish'

from webapps-deploy.

ianrandell-sh avatar ianrandell-sh commented on August 14, 2024 1

@joeystdio - perfect! I've been trying for hours to get it to work. The key for me was getting the files deployed to the right place, i.e under app_data/jobs/continuous.

I couldn't find a single piece of documentation that explained how to do the whole thing. Wish I'd hit your post above sooner- would've saved me going round the houses.

Note: the above also works with azure login rather than publish profiles which didnt work for me, ie:

      # ---------------------------------------------
      # Login using Service-Principal-type secret
      # See: https://docs.microsoft.com/en-us/azure/app-service/deploy-github-actions?tabs=userlevel#configure-the-github-secret
      # ---------------------------------------------
      - uses: azure/login@v1
        with:
          creds: ${{secrets.AZURE_WEBJOB_CREDENTIALS_DEV}}

      # Deploy to Azure Web apps
      - name: Deploy to Azure App Service ${{env.AZURE_APPSERVICE_NAME}}
        uses: azure/webapps-deploy@v2
        with: 
          app-name: '${{env.AZURE_APPSERVICE_NAME}}'
          package: '${{env.PUBLISH_OUTPUT_ROOT}}'
      
      - name: logout
        run: |
          az logout

from webapps-deploy.

ehamai avatar ehamai commented on August 14, 2024

@srijken - Web jobs are just regular file content, so there shouldn't be anything special required in order to deploy them. Building them may be a different story of course, but for this repo which is specific to the deployment action, I don't see why it would be anything different. Are you running into issues with it?

from webapps-deploy.

github-actions avatar github-actions commented on August 14, 2024

This issue is stale because it has been open for 14 days with no activity. Please remove the stale label or comment on the issue otherwise this will be closed in 5 days

from webapps-deploy.

warrenkc avatar warrenkc commented on August 14, 2024

Hi. I had a very hard time getting this to work for .Net Core 7.0 WebJob for Azure App Service using GitHub Action Workflow.

Hopefully this helps someone else.
It fails if I try to use ubuntu with Error: Process completed with exit code 1.

name: Deploy WebJob

on:
  push:
      branches:
        - master
  workflow_dispatch:

env:
  WEBJOB_NAME: DotNetWorker
  AZURE_APP_NAME: 'webjob-xpert'
  PROJECT_ROOT: ./DotNetWorker
  DOTNET_VERSION: '7.0.x'

jobs:
  build:
    runs-on: windows-latest

    steps:
    # Checkout the repo
    - uses: actions/checkout@v2

    # Setup .NET Core SDK
    - name: Setup .NET Core
      uses: actions/setup-dotnet@v1
      with:
        dotnet-version: ${{ env.DOTNET_VERSION }}
    
    #- name: dotnet test
    #  run: |
    #    dotnet test ${{ env.TEST_PROJECT_ROOT }}

    - name: dotnet publish
      run: |
        dotnet restore
        dotnet build --configuration Release
        dotnet publish -c Release -o './publish/App_Data/Jobs/Continuous/${{ env.WEBJOB_NAME }}' ${{ env.PROJECT_ROOT }}
        
    - name: Deploy to Azure App Service
      uses: azure/webapps-deploy@v2
      with: 
        app-name: ${{ env.AZURE_APP_NAME }}
        publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_99DA0552C0F24762B786220FDECEA669 }}        
        package: ./publish

from webapps-deploy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.