admin管理员组

文章数量:1189998

I'm trying to deploy a .NET 8 Function App with the isolated worker model using Azure DevOps. My pipeline works perfectly for a .NET 6 in-process Function App, but after adjusting it for .NET 8 and the isolated worker model, the deployment appears to succeed without any errors. However, when I check the Azure portal, the Function App doesn't show any deployed functions.

Here is the pipeline I'm using after updating the .NET version:

parameters:
  - name: DEPLOY_INFRA
    displayName: Deploy infrastructure
    type: string
    default: no
    values:
      - yes
      - no

trigger:
  batch: true
  branches:
    include:
      - main
  paths:
    include:
      - deployments/*

pr:
  autoCancel: true
  drafts: false
  branches:
    include:
      - main

variables:
  DEV_CONNECTION: "DEV-SERVICE-CONNECTION"
  PRD_CONNECTION: "PRD-SERVICE-CONNECTION"
  REGION: "westeurope"
  TERRAFORM_DIR: "iac/terraform"
  WAIT_TIME: "30"

  DEV_ENV: "backend-dev-env"
  PRD_ENV: "backend-prd-env"

  DEV_APP_NAME: "dev-app-func"
  PRD_APP_NAME: "prd-app-func"

  DOTNET_VERSION: "8.0.x"
  CONFIGURATION: "Release"

stages:
  - stage: PrepareArtifacts
    displayName: "Prepare Artifacts"
    condition: always()
    pool:
      vmImage: "ubuntu-latest"
    jobs:
      - job: BuildFunctions
        displayName: "Build Functions"
        steps:
          - task: UseDotNet@2
            displayName: "Install .NET SDK 8.0.x"
            inputs:
              packageType: sdk
              version: $(DOTNET_VERSION)

          - task: DotNetCoreCLI@2
            displayName: "Restore Project"
            inputs:
              command: restore
              projects: deployments/FunctionApp/FunctionApp.csproj
              feedsToUse: config
              nugetConfigPath: deployments/FunctionApp/nuget.config

          - task: DotNetCoreCLI@2
            displayName: "Build Project"
            inputs:
              command: build
              projects: deployments/FunctionApp/FunctionApp.csproj
              arguments: "--no-restore --configuration $(CONFIGURATION)"

          - task: DotNetCoreCLI@2
            displayName: "Publish Function App"
            inputs:
              command: publish
              publishWebProjects: false
              projects: deployments/FunctionApp/FunctionApp.csproj
              arguments: "--no-build --configuration $(CONFIGURATION) --output $(Build.ArtifactStagingDirectory)/packages/app"
              zipAfterPublish: true

          - script: |
              echo "Contents of $(Build.ArtifactStagingDirectory)/packages:"
              find $(Build.ArtifactStagingDirectory)/packages -type f
            displayName: "Debug: List Files in Packages Directory"

          - task: PublishPipelineArtifact@1
            inputs:
              targetPath: "$(Build.ArtifactStagingDirectory)/packages"
              artifact: "packages"

  - ${{ if eq(parameters.DEPLOY_INFRA, 'yes') }}:
    - stage: DeployInfraDev
      dependsOn: PrepareArtifacts
      condition: succeeded('PrepareArtifacts')
      displayName: "Deploy Infrastructure to Dev"
      pool:
        vmImage: "ubuntu-latest"
      jobs:
        - job: "TerraformPlan"
          displayName: "Terraform Plan"
          steps:

            - template: azure-pipeline-steps-terraform.yaml
              parameters:
                workingDirectory: $(TERRAFORM_DIR)
                serviceConnection: $(DEV_CONNECTION)
                env: "dev"
                region: $(REGION)

        - job: WaitForValidation
          displayName: "Wait for Manual Approval"
          dependsOn:
            - TerraformPlan
          pool: server
          timeoutInMinutes: $(WAIT_TIME)

          steps:
            - task: ManualValidation@0
              timeoutInMinutes: $(WAIT_TIME)
              inputs:
                instructions: "Please review the Terraform plan before approving."
                onTimeout: "reject"

        - job: "TerraformApply"
          displayName: "Terraform Apply"
          dependsOn:
            - WaitForValidation
          steps:
            - template: azure-pipeline-steps-terraform.yaml
              parameters:
                workingDirectory: $(TERRAFORM_DIR)
                serviceConnection: $(DEV_CONNECTION)
                env: "dev"
                region: $(REGION)
                dryRun: false

  - ${{ if eq(parameters.DEPLOY_INFRA, 'yes') }}:
    - stage: DeployFunctionToDev
      displayName: "Deploy Function App to Dev"
      dependsOn: DeployInfraDev
      condition: succeeded('DeployInfraDev')
      pool:
        vmImage: "ubuntu-latest"
      jobs:
        - deployment:
          environment: $(DEV_ENV)
          strategy:
            runOnce:
              deploy:
                steps:
                  - task: DownloadPipelineArtifact@2
                    displayName: "Download Artifacts"
                    inputs:
                      artifactName: "packages"
                      targetPath: "$(Pipeline.Workspace)"

                  - script: |
                      echo "Listing all files in workspace:"
                      find $(Pipeline.Workspace) -type f
                    displayName: "Verify Downloaded Artifacts"
                  
                  - task: AzureFunctionApp@1
                    displayName: "Deploy Function App"
                    inputs:
                      azureSubscription: $(DEV_CONNECTION)
                      appName: $(DEV_APP_NAME)
                      package: "$(Pipeline.Workspace)/packages/app/FunctionApp.zip"

本文标签: