Azure DevOps Pipeline for NodeJs Azure函数随机失败

3gtaxfhh  于 2023-10-17  发布在  Node.js
关注(0)|答案(2)|浏览(131)

我有一个Azure DevOps Pipeline,用于在Node.Js中编写的Azure Function,它有时会失败,比如 * 5次中有3次失败 *,并出现以下错误:

Deployment has been stopped due to SCM container restart. The restart can happen due to a management operation on site. Do not perform a management operation and a deployment operation in quick succession. Adding a small delay can help avoid any conflicts.

作为该函数的更多上下文,我不能把代码用于不同的原因,但该函数在 * Puppeteer* 周围发生了一些变化,这些变化用于生成一些报告。

steps:
- task: PowerShell@2
  inputs:
    targetType: 'inline'
    script: |
      New-Item -Path $(Build.SourcesDirectory)/.deployment -ItemType File
      '[config] SCM_DO_BUILD_DURING_DEPLOYMENT = true' | out-file -filepath $(Build.SourcesDirectory)/.deployment
- task: ArchiveFiles@2
  displayName: 'Zip source'
  inputs:
    rootFolderOrFile: '$(Build.SourcesDirectory)'
    includeRootFolder: false
    archiveType: 'zip'
    archiveFile: '$(Build.ArtifactStagingDirectory)/source.zip'
    replaceExistingArchive: true
- task: PublishBuildArtifacts@1
  displayName: 'Publish zip'
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)/source.zip'
    ArtifactName: 'report-source'
    publishLocation: 'Container'

我找不到任何关于此错误的信息,并且在日志中移动没有任何其他额外的信息。

"puppeteer": "^21.3.1"

编辑:
1.我在函数应用程序配置中添加了WEBSITES_CONTAINER_START_TIME_LIMIT:1800,没有改进。
1.我在DevOps Release中的发布步骤之前添加了一个'wait 30s task',没有改进

n9vozmp4

n9vozmp41#

根据错误消息,这可能是由于您正在重新启动SCM容器期间进行部署,请在Azure上重新启动应用程序并等待它完成,添加一些时间延迟,例如:180年代,你可以减少时间,如果它的工作后。然后重试管道。

sshcrbum

sshcrbum2#

为了解决您的错误,请参阅此answer by VenkateshDodda-MSFT >在您的功能应用程序配置设置中添加**WEBSITES_CONTAINER_START_TIME_LIMIT:1800**,如下所示:-
DevOps部署后的My Function应用配置设置:-

我已经通过运行下面的命令在我的函数应用程序中添加了pupeeteer库:

npm i puppeteer

我的包。json:-

{
  "name": "noejsfunction",
  "version": "1.0.0",
  "description": "",
  "scripts": {
    "start": "func start",
    "test": "echo \"No tests yet...\""
  },
  "dependencies": {
    "puppeteer": "^21.3.7"
  }
}

我的DevOps yaml脚本:-

选择以下选项:-

trigger:
- main

variables:

  
  azureSubscription: 'xxxxx-37646e944376'

 
  functionAppName: 'siliconfunc43'

  
  environmentName: 'siliconfunc43'

 
  vmImageName: 'ubuntu-latest'

stages:
- stage: Build
  displayName: Build stage
  jobs:
  - job: Build
    displayName: Build
    pool:
      vmImage: $(vmImageName)

    steps:
    - task: NodeTool@0
      inputs:
        versionSpec: '10.x'
      displayName: 'Install Node.js'

    - script: |
        if [ -f extensions.csproj ]
        then
            dotnet build extensions.csproj --runtime ubuntu.16.04-x64 --output ./bin
        fi
      displayName: 'Build extensions'

    - script: |
        npm install
        npm run build --if-present
        npm run test --if-present
      displayName: 'Prepare binaries'

    - task: ArchiveFiles@2
      displayName: 'Archive files'
      inputs:
        rootFolderOrFile: '$(System.DefaultWorkingDirectory)'
        includeRootFolder: false
        archiveType: zip
        archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
        replaceExistingArchive: true

    - upload: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
      artifact: drop

- stage: Deploy
  displayName: Deploy stage
  dependsOn: Build
  condition: succeeded()
  jobs:
  - deployment: Deploy
    displayName: Deploy
    environment: $(environmentName)
    pool:
      vmImage: $(vmImageName)
    strategy:
      runOnce:
        deploy:
          steps:
          - task: AzureFunctionApp@1
            displayName: 'Azure Functions App Deploy: siliconfunc43'
            inputs:
              azureSubscription: '$(azureSubscription)'
              appType: functionAppLinux
              appName: $(functionAppName)
              package: '$(Pipeline.Workspace)/drop/$(Build.BuildId).zip'

输出:-

检查函数日志流以获得有关错误的更多见解,并参考我的SO线程答案来监控您的函数应用程序和触发器,并获得有关错误的具体见解:

相关问题