CI/CD Pipeline with GitHub Actions for a .NET 7.0 Durable Function App

Wonderful World 116 Reputation points
2023-07-13T12:42:55.7833333+00:00

After going through many documents, I can't find the right way to create a CI/CD pipeline for a .NET 7.0 Durable Function App. I want to deploy the durable function app to Azure.

Repository: Durable Function App

CI/CD: GitHub Actions

Storage Provider: Netherite

I have an Azure Static Web App already running in Azure. There is a sample Static Web App GitHub Action template available from where all can be created. I could not find something similar for Durable Function App.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,909 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ryan Hill 30,281 Reputation points Microsoft Employee Moderator
    2023-07-14T21:42:36.1666667+00:00

    @Wonderful World there shouldn't continuous deployment You should be able to leverage this example workflow file as your GitHub action. Once your pipeline builds the project, the Azure/functions-action@v1 task will deploy your artifacts to your function app and the platform will recognize the function.json.

    If you're having deployment issues, please feel free to share the errors that you're receiving in a comment down below.


    EDIT 28 Aug: Based off the comments down below, you want to go down the Infrastructure as Code path. You can achieve this using GitHub actions. This blog post is a good example of how to implement the basic structure. You would build step will build your application, publish those artifacts along with your IaC.

      build:
        name: build phase
        runs-on: ubuntu-latest
    
        steps:
          - name: Checkout
            uses: actions/checkout@v3
          
          - name: Build and Publish app
            run: dotnet publish ./webapp/ --configuration Release /property:GenerateFullPaths=true /consoleloggerparameters:NoSummary
          
          - name: Publish app artifact
            uses: actions/upload-artifact@v3
            with:
              name: app
              path: "./webapp/bin/Release/net6.0/publish/"
    
          - name: Publish Infra artifact
            uses: actions/upload-artifact@v3
            with:
              name: infra
              path: "./Infra/"
    

    Next you, use deployDevInfrastructure that's mentioned in the blog post to execute your infrastructure code. This assumes your IaC code is a folder named

      deployDevInfrastructure:
        needs: build
        name: deploy dev infrastructure
        runs-on: ubuntu-latest
    
        steps:
          - name: Download infra
            uses: actions/download-artifact@v3
            with:
              name: infra
              path: infra
          
          - name: Login to Azure CLI
            uses: azure/login@v1
            with:
              creds: ${{ secrets.AZURE_CREDENTIALS }}
    
          - name: Deploy infrastructure
            id: azure-deployment
            shell: pwsh
            run: |
              $rgName = '${{ env.RG_NAME }}'
    
              $(az deployment create --name $rgName `
                --location ${{ env.LOCATION }} `
                --template-file main.bicep `
                --parameters location=${{ env.LOCATION }} `
                --parameters rgName=$rgName `
                --output json) | ConvertFrom-Json
            
            working-directory: ./infra/
    

    You'll notice that --template-file refers to a main.bicep. If you want to use ARM, you would reference your ARM template file. Running the az deployment create command is what takes your IaC code and deploys

    From this end of the CI/CD pipeline, you don't really need concern with source control because you're using the pipeline to push the code to the PaaS. Source control comes into play if you were using PaaS to pull the code from a repository.

    The next step is deploying the app once the infrastructure has been deployed.

      deployDevApp:
        needs: deployDevInfrastructure
        name: deploy dev application
        runs-on: ubuntu-latest
        
        steps:
          - name: Download app
            uses: actions/download-artifact@v3
            with:
              name: app
              path: app
    
          - name: Deploy to Azure Web App
            id: deploy-to-webapp
            uses: azure/webapps-deploy@v2
            with:
              app-name: '${{ needs.deployDevInfrastructure.outputs.appName }}'
              slot-name: 'Production'
              publish-profile: ${{ needs.deployDevInfrastructure.outputs.publishProfiles }}
              package: ./app
    

    The deployDevInfrastructure uses powershell, so to gather the outputs, just set a variable name and configure it to the outputs property.

        outputs:
          appName: ${{ steps.azure-deployment.outputs.appName }}
          publishProfiles: ${{ steps.azure-deployment.outputs.publishProfiles }}
    

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.