Azure DevOps 成功的持续集成/持续部署之后,Azure FunctionApp 中没有函数。

huangapple go评论59阅读模式
英文:

Azure FunctionApp without functions after successful CI/CD over Azure DevOps

问题

我创建了一个运行在 App Service Plan Y1 上的 Azure 函数应用(Linux),并在 Azure DevOps Git 中存储我的源代码。这些函数是使用 C# 在 .NET 6 上编写的。

下面是我的 CI 和分开的 CD 管道的 YAML 定义。当我执行管道时,一切都正常运行(两者都是绿色的)。然而,在部署之后,这是我的 Azure 门户在“Functions”选项卡中的样子:

Azure DevOps 成功的持续集成/持续部署之后,Azure FunctionApp 中没有函数。

使用 VS Code Azure 扩展并查看函数应用的文件时,我得到了以下信息:

Azure DevOps 成功的持续集成/持续部署之后,Azure FunctionApp 中没有函数。

当我查看 CI 管道的构建产物时,一切看起来都很正常(已下载 zip 文件的资源管理器视图):

Azure DevOps 成功的持续集成/持续部署之后,Azure FunctionApp 中没有函数。

"bin" 文件夹中有内容。

一些关键点:

  • 函数应用中没有槽位(slots)。
  • 部署在相关的应用洞察(App Insights)中可见。
  • 我的参考点是 Microsoft Learn

因此,在 VS Code 中搜索时是否会得到 404 是正常的,或者有人有类似的经验,甚至知道解决方案吗?

附注:

以前我使用 VS Code 进行扩展安装来部署我的函数。但是今天在部署后,我收到了一个奇怪的错误消息:

Azure DevOps 成功的持续集成/持续部署之后,Azure FunctionApp 中没有函数。

CI YAML

pool:
    vmImage: 'ubuntu-latest'

trigger: none

variables:
    - name: 'Solution'
      value: '**/MyProject.sln'
    - name: 'ProjectFilter'
      value: '**/*.csproj'    
    - name: 'BuildConfiguration'
      value: 'Release'

steps:   
    - task: UseDotNet@2
      displayName: Use DotNet 6
      inputs:
          version: '6.0.x'
    - task: DotNetCoreCLI@2
      displayName: Restore
      inputs:
          command: restore
          projects: '$(ProjectFilter)'
    - task: DotNetCoreCLI@2
      displayName: Build
      inputs:
          projects: '$(ProjectFilter)'
          arguments: '--no-restore --configuration $(BuildConfiguration)'    
    - task: DotNetCoreCLI@2
      displayName: Publish Image Converter
      inputs:
          command: publish
          projects: src/Functions/**/MyProject.csproj
          publishWebProjects: false
          arguments: '--no-restore --no-build --configuration $(BuildConfiguration) --output $(Build.DefaultWorkingDirectory)/function_publish_output'
          zipAfterPublish: false
    - task: ArchiveFiles@2
      displayName: Archive Image Converter
      inputs:
          rootFolderOrFile: '$(Build.DefaultWorkingDirectory)/function_publish_output'
          includeRootFolder: false
          archiveFile: '$(Build.ArtifactStagingDirectory)/MyProject.zip'
    - task: PublishBuildArtifacts@1
      displayName: 'Publish Artifact'
      inputs:
          PathtoPublish: '$(Build.ArtifactStagingDirectory)'
      condition: succeededOrFailed()

CD YAML

variables:
  - name: 'vmImageName'
    value: 'ubuntu-latest'
  - name: 'serviceConnectionName'
    value: 'MYCONN'
  - name: 'project'
    value: 'MYPROJECT'

resources:
  pipelines:
    - pipeline: ci
      source: 'NAMEOFCI'
      trigger: true

pool:
  vmImage: $(vmImageName)

trigger: none

stages:
  - stage: Production
    displayName: Production
    jobs:
      - deployment: Deploy
        displayName: 'Deploy'
        environment: 'Production'
        pool:
          vmImage: $(vmImageName)
        strategy:
          runOnce:
            deploy:
              steps:
                - download: ci
                  displayName: 'Download Artifact'
                  artifact: drop
                - task: AzureFunctionApp@1
                  displayName: 'Deploy Image Converter Function'
                  inputs:
                    azureSubscription: '$(serviceConnectionName)'
                    appType: functionAppLinux
                    appName: 'fapp-**********-prod'
                    package: '$(Pipeline.Workspace)/ci/drop/MyProject.zip'
                    runtimeStack: 'DOTNET|6.0'

更新

我决定重新部署我的函数,并在从 Y1 切换到 S1 后,可以再次直接使用 VS Code 进行部署。使用 Azure DevOps 管道仍然会在那里显示绿色的勾,但在门户中看不到函数触发器。切换回 Y1 后,VS Code 中的错误会再次出现。

英文:

I've created an Azure Function App (Linux) running on an App Service Plan Y1 and have my sources in Azure DevOps Git. The functions are written in C# on DOTNET 6.

Below you can see my YAML definitions for the CI and a separated CD pipeline. When I execute the pipeline everything works well (both are green). After the deployment however this is how my Azure Portal looks in the Functions blade:

Azure DevOps 成功的持续集成/持续部署之后,Azure FunctionApp 中没有函数。

Using the VS Code Azure Extension and looking into the files of the function app I get:

Azure DevOps 成功的持续集成/持续部署之后,Azure FunctionApp 中没有函数。

When I look in the artifact of the CI pipeline everything looks good (explorer view of the downloaded zip):

Azure DevOps 成功的持续集成/持续部署之后,Azure FunctionApp 中没有函数。

The bin-folder is populated there.

Some key points:

  • I have no slots in the function app.
  • The deployments are visible in the associated App Insights.
  • My reference point is Microsoft Learn

So is it normal to get the 404 when searching in VS code and did somebody experience something similar or even know the solution?

Sidenote:

I used to deploy my function using VS Code with extensions install. Today I now get a weired error message after the deployment:

Azure DevOps 成功的持续集成/持续部署之后,Azure FunctionApp 中没有函数。

CI YAML

pool:
    vmImage: 'ubuntu-latest'

trigger: none

variables:
    - name: 'Solution'
      value: '**/MyProject.sln'
    - name: 'ProjectFilter'
      value: '**/*.csproj'    
    - name: 'BuildConfiguration'
      value: 'Release'

steps:   
    - task: UseDotNet@2
      displayName: Use DotNet 6
      inputs:
          version: '6.0.x'
    - task: DotNetCoreCLI@2
      displayName: Restore
      inputs:
          command: restore
          projects: '$(ProjectFilter)'
    - task: DotNetCoreCLI@2
      displayName: Build
      inputs:
          projects: '$(ProjectFilter)'
          arguments: '--no-restore --configuration $(BuildConfiguration)'    
    - task: DotNetCoreCLI@2
      displayName: Publish Image Converter
      inputs:
          command: publish
          projects: src/Functions/**/MyProject.csproj
          publishWebProjects: false
          arguments: '--no-restore --no-build --configuration $(BuildConfiguration) --output $(Build.DefaultWorkingDirectory)/function_publish_output'
          zipAfterPublish: false
    - task: ArchiveFiles@2
      displayName: Archive Image Converter
      inputs:
          rootFolderOrFile: '$(Build.DefaultWorkingDirectory)/function_publish_output'
          includeRootFolder: false
          archiveFile: '$(Build.ArtifactStagingDirectory)/MyProject.zip'
    - task: PublishBuildArtifacts@1
      displayName: 'Publish Artifact'
      inputs:
          PathtoPublish: '$(Build.ArtifactStagingDirectory)'
      condition: succeededOrFailed()

CD YAML

variables:
  - name: 'vmImageName'
    value: 'ubuntu-latest'
  - name: 'serviceConnectionName'
    value: 'MYCONN'
  - name: 'project'
    value: 'MYPROJECT'

resources:
  pipelines:
    - pipeline: ci
      source: 'NAMEOFCI'
      trigger: true

pool:
  vmImage: $(vmImageName)

trigger: none

stages:
  - stage: Production
    displayName: Production
    jobs:
      - deployment: Deploy
        displayName: 'Deploy'
        environment: 'Production'
        pool:
          vmImage: $(vmImageName)
        strategy:
          runOnce:
            deploy:
              steps:
                - download: ci
                  displayName: 'Download Artifact'
                  artifact: drop
                - task: AzureFunctionApp@1
                  displayName: 'Deploy Image Converter Function'
                  inputs:
                    azureSubscription: '$(serviceConnectionName)'
                    appType: functionAppLinux
                    appName: 'fapp-**********-prod'
                    package: '$(Pipeline.Workspace)/ci/drop/MyProject.zip'
                    runtimeStack: 'DOTNET|6.0'

UPDATE

I decided to redeploy my function and could deploy using VS Code directly again when switching from Y1 to S1. Using the Azure DevOps Pipeline still gives me a green checkmark there but no function triggers visible in the portal. Switching back to Y1 brings the error in VS Code back.

答案1

得分: 1

我们遇到了类似的问题,不得不向应用设置中添加了一个参数。在我们的情况下,是直接通过 Terraform 添加的。

app_settings = {
 WEBSITE_RUN_FROM_PACKAGE = "1"
}

祝好运。

英文:

we had a similar issue and had to add a parameter to app settings. In our case directly via terraform.

app_settings = {
 WEBSITE_RUN_FROM_PACKAGE = "1"
}

Cheers

答案2

得分: 0

你可以检查文件系统上确切看到的内容吗?您可以使用控制台或高级工具:

Azure DevOps 成功的持续集成/持续部署之后,Azure FunctionApp 中没有函数。

英文:

Can you check what exactly you see on the file system? You can use console or Advanced tools:

Azure DevOps 成功的持续集成/持续部署之后,Azure FunctionApp 中没有函数。

huangapple
  • 本文由 发表于 2023年2月18日 02:49:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/75488247.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定