简体   繁体   English

使用YAML管道部署Azure Function

[英]Using YAML pipeline to deploy Azure Function

I'm trying to build and deploy an Azure Function using YAML pipelines.我正在尝试使用 YAML 管道构建和部署 Azure Function。 The build and publish stage works fine, it produces a zip file which I can download.构建和发布阶段工作正常,它生成一个 zip 文件,我可以下载它。 However my deployment stage keeps failing with the following error: No package found with specified pattern: D:\a\1\drop\output.zip但是我的部署阶段一直失败并出现以下错误:没有找到具有指定模式的 package:D:\a\1\drop\output.zip

I've tried using different environment variables and back/forward slash in the path.我试过在路径中使用不同的环境变量和后/前斜杠。

Note, that the vmImageName is set to 'windows-latest'请注意,vmImageName 设置为“windows-latest”

Output of the deployment stage:部署阶段Output:

  • Downloading: D:\a\1/drop/output.zip下载:D:\a\1/drop/output.zip
  • Error: No package found with specified pattern: D:\a\1\drop\output.zip错误:找不到具有指定模式的 package:D:\a\1\drop\output.zip

What am I missing?我错过了什么?

Build and publish stage:构建和发布阶段:

- stage: Build
  displayName: Build solution
  jobs:  
  - job: Build
    displayName: Build and publish solution
    pool:
      vmImage: $(vmImageName)
      workspace:
            clean: all
    steps:
    - checkout: self
    - checkout: AzureUtil

    - task: DotNetCoreCLI@2
      displayName: Build and Publish Azure Function
      inputs:
        command: publish
        arguments: '--configuration Release --output publish_output'
        projects: $(projectsPath)/$(projectFileName)
        publishWebProjects: false
        modifyOutputPath: false
        zipAfterPublish: false

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

    - task: PublishBuildArtifacts@1
      displayName: "Publish build artifacts"
      inputs:
        PathtoPublish: $(Build.ArtifactStagingDirectory)\output.zip'
        artifactName: 'drop'

Deployment stage:部署阶段:

- stage: Deploy
  displayName: Deploy Azure Function
  dependsOn: Build
  condition: succeeded()
  jobs:
    - deployment: Deploy
      displayName: Deploy Azure Function
      pool:
        vmImage: $(vmImageName)
      environment: 'Web-Dev'
      strategy:
        runOnce:
          deploy:
            steps:
            - task: AzureFunctionApp@1
              displayName: 'Azure functions app deploy'
              inputs:
                azureSubscription: '$(serviceConnectionName)'
                appType: functionApp
                appName: '$(azureFunctionName)'
                package: '$(Pipeline.Workspace)\drop\output.zip' 

I tried to Deploy Azure Function to Function app via YAML pipeline and it was successful.我尝试通过 YAML 管道将 Azure Function 部署到 Function 应用程序,它成功了。

Created a.Net Http Trigger in my Visual studio pushed the Code to Azure Devops Repository and used default YAML pipeline below:-在我的 Visual Studio 中创建了一个 .Net Http 触发器,将代码推送到 Azure Devops 存储库,并使用下面的默认 YAML 管道:-

Azure DevOps Repository:- Azure DevOps 存储库:-

在此处输入图像描述

Default Pipeline:-默认管道:-

在此处输入图像描述

YAML pipeline code below referred from this Github link :- YAML 以下管道代码来自此Github 链接:-

 # .NET Core Function App to Windows on Azure # Build a .NET Core function app and deploy it to Azure as a Windows function App. # Add steps that analyze code, save build artifacts, deploy, and more: # https://docs.microsoft.com/en-us/azure/devops/pipelines/languages/do.net-core trigger: - master variables: # Azure Resource Manager connection created during pipeline creation azureSubscription: 'xxxx-xxx-xxx-98e7-e2dxxxxx' # Function app name functionAppName: 'siliconfunc43' # Agent VM image name vmImageName: 'windows-2019' # Working Directory workingDirectory: '$(System.DefaultWorkingDirectory)/FunctionApp8' stages: - stage: Build displayName: Build stage jobs: - job: Build displayName: Build pool: vmImage: $(vmImageName) steps: - task: DotNetCoreCLI@2 displayName: Build inputs: command: 'build' projects: | $(workingDirectory)/*.csproj arguments: --output $(System.DefaultWorkingDirectory)/publish_output --configuration Release - task: ArchiveFiles@2 displayName: 'Archive files' inputs: rootFolderOrFile: '$(System.DefaultWorkingDirectory)/publish_output' includeRootFolder: false archiveType: zip archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip replaceExistingArchive: true - publish: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip artifact: drop - stage: Deploy displayName: Deploy stage dependsOn: Build condition: succeeded() jobs: - deployment: Deploy displayName: Deploy environment: 'development' pool: vmImage: $(vmImageName) strategy: runOnce: deploy: steps: - task: AzureFunctionApp@1 displayName: 'Azure functions app deploy' inputs: azureSubscription: '$(azureSubscription)' appType: functionApp appName: $(functionAppName) package: '$(Pipeline.Workspace)/drop/$(Build.BuildId).zip'

In the last step add:-在最后一步添加:-

package: '$(Pipeline.Workspace)/drop/$(Build.BuildId).zip'

Output:- Output:-

在此处输入图像描述

在此处输入图像描述

Function got deployed and triggered successfully, Refer below:- Function 已部署并成功触发,请参考以下内容:-

在此处输入图像描述

在此处输入图像描述

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

相关问题 使用 YAML 管道构建和部署多个 azure function 项目 - Build and Deploy multiple azure function projects using YAML pipeline 覆盖变量 Azure Yaml 管道不工作 - Overwrite Variable in Azure Yaml Pipeline not working azure devops yaml 管道未设置变量 - azure devops yaml pipeline not setting the variables Azure DevOps 管道 yaml 文件 Docker 标签 - Azure DevOps Pipeline yaml file Docker Tag YAML Azure DevOps 管道上的解析器错误 - YAML Parser error on Azure DevOps Pipeline 如何使用 YAML 从 Azure Devops 管道执行和安排 Databricks Notebook - How can I execute and schedule Databricks notebook from Azure Devops Pipeline using YAML 如何构建、package 和部署 AWS SAM lambda function 从 azure Devops CI/CD 管道到 AWS - how to build, package and deploy AWS SAM lambda function of python from azure Devops CI/CD pipeline to AWS Bitbucket 使用 Azure-cli 命令部署到 Azure VM 的管道无法访问脚本文件 - Bitbucket pipeline to deploy to Azure VM using Azure-cli command cannot access to script file 使用 bitbucket 管道在 .netcore 3 中部署 Azure 函数 - Deploy Azure Functions in netcore 3 with bitbucket pipeline 使用 Aure Container Registry 部署失败 Azure Function - Failed to deploy Azure Function using Aure Container Registry
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM