简体   繁体   English

Azure DevOps - 部署问题

[英]Azure DevOps - Deployment problems

I am trying to deploy a new code in an existing function on Azure but for some reason I am getting a Green/Pass pipeline but when I request the URL I got error 404.我正在尝试在 Azure 上的现有 function 中部署新代码,但由于某种原因,我得到了 Green/Pass 管道,但是当我请求 ZE6B391A8D2C4D45902A23A8B650845703 错误时

What I have done:我做了什么:

  1. Setup the function manually手动设置 function

  2. Run a Pipeline with the stages:运行具有阶段的管道:

    a) mvn package a) mvn package

    b) zip content of azure functions in the target b) 目标中 azure 函数的 zip 内容

    c) Deploy artifact from agent to the pipeline c) 将工件从代理部署到管道

    d) Deploy artifact into a function using snipped code from microsoft. d) 使用 microsoft 的截断代码将工件部署到 function 中。

The pipeline gets a green state and the function has been deployed:管道获得绿色 state 和 function 已部署:

Starting: AzureFunctionApp
==============================================================================
Task         : Azure Functions
Description  : Update a function app with .NET, Python, JavaScript, PowerShell, Java based web applications
Version      : 1.195.0
Author       : Microsoft Corporation
Help         : https://aka.ms/azurefunctiontroubleshooting
==============================================================================
Got service connection details for Azure App Service:'test'
Trying to update App Service Application settings. Data: {"WEBSITE_RUN_FROM_PACKAGE":"https://teststorage.blob.core.windows.net/azure-pipelines-deploy/package_1639741028399.zip?***"}
Updated App Service Application settings.
Updated WEBSITE_RUN_FROM_PACKAGE Application setting to https://teststorage.blob.core.windows.net/azure-pipelines-deploy/package_1639743928399.zip?***
Syncing triggers for function app
Sync triggers for function app completed successfully
Successfully added release annotation to the Application Insight :test
App Service Application URL: http://test.azurewebsites.net
Finishing: AzureFunctionApp

but when I request the URL it fails, also I check the functions section in the portal, and the function that was there (deployed manually) got removed.但是当我请求 URL 它失败时,我还检查了门户中的功能部分,并且那里的 function (手动部署)被删除了。

Note: The code is fine because I can deploy manually the same code and it is working fine, via pipeline is not working.注意:代码很好,因为我可以手动部署相同的代码并且工作正常,通过管道不起作用。

Pipeline code:管道代码:

pool:
  vmImage: ubuntu-latest

variables:
  serviceName: test
  jdkVersion: "1.11"

stages:
  - stage:
    displayName: Build
    jobs:
      - job: "Deployment_draft"
        steps:
          - task: MavenAuthenticate@0
            displayName: "Maven Authenticate"
            inputs:
              artifactsFeeds: test-artifactory
          - task: ArchiveFiles@2
            inputs:
              rootFolderOrFile: $(Build.SourcesDirectory)/${{ variables.serviceName }}/target/azure-functions/${{ variables.serviceName }}
              includeRootFolder: true
              archiveType: 'zip'
              archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
              replaceExistingArchive: true
          - task: PublishBuildArtifacts@1
            inputs:
              PathtoPublish: '$(Build.ArtifactStagingDirectory)'
              ArtifactName: '${{ variables.serviceName }}'
              publishLocation: 'Container'
          - task: AzureFunctionApp@1
            inputs:
              azureSubscription: 'SubscriptionTest(Subscription ID)'
              appType: 'functionAppLinux'
              appName: 'test'
              deploymentMethod: zipDeploy
              package: '$(Build.ArtifactStagingDirectory)/**/*.zip'



rootFolderorFile - Enter the root folder or file path to add to the archive. rootFolderorFile - 输入要添加到存档的根文件夹或文件路径。 If a folder, everything under the folder will be added to the resulting archive.如果是文件夹,则该文件夹下的所有内容都将添加到生成的存档中。 Default value: $(Build.BinariesDirectory)默认值:$(Build.BinariesDirectory)

I have slightly modified your pipeline.我稍微修改了你的管道。

 pool:
    vmImage: ubuntu-latest

variables:
    serviceName: test
    jdkVersion: "1.11"

stages:
- stage:
    displayName: Build
jobs:
    - job: "Deployment_draft"

steps:
- task: MavenAuthenticate@0
    displayName: "Maven Authenticate"
inputs:
    artifactsFeeds: test-artifactory


- stage : deploy
    jobs:
    - job:
    displayName : Function App update
    
steps:
- task: ArchiveFiles@2
    inputs:
        rootFolderOrFile: '$(Build.SourcesDirectory)'
        includeRootFolder: true
        archiveType: 'zip'
        archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
        replaceExistingArchive: true
- task: PublishBuildArtifacts@1
    inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
    ArtifactName: '${{ variables.serviceName }}'
    publishLocation: 'Container'

- task: AzureFunctionApp@1
    inputs:
        azureSubscription: 'SubscriptionTest(Subscription ID)'
        appType: 'functionAppLinux'
        appName: 'test'
        deploymentMethod: zipDeploy
        package: '$(Build.ArtifactStagingDirectory)/**/*.zip'

Refer here参考这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM