如何为 powershell azure 函数应用程序创建 azure 构建管道

问题描述 投票:0回答:1

我正在从 python 函数应用程序迁移到 powershell 函数应用程序。我有一个为此构建和发布的管道。下面的代码是 python 函数应用程序的构建。我该如何为 powershell 函数应用程序执行此操作。

#------------------------------------------------------------------------------------
#parametrise service connection detials 
#------------------------------------------------------------------------------------
variables:
  azureServiceConnection: 'my-service-connection'
# -------------------------------------------------------------------------------------
# What VM OS will run this pipeline
# -------------------------------------------------------------------------------------
pool:
  vmImage: 'ubuntu-latest'
# -------------------------------------------------------------------------------------
# A Build pipeline is definined in a hierarchy of Stages > Jobs > Steps,
# This example has a single stage and job and therefore those don't need to be listed
# -------------------------------------------------------------------------------------
steps:
- bash: |
   if [ -f extensions.csproj ]
   then
       dotnet build extensions.csproj --output ./bin
   fi
  displayName: 'Build extensions'

- task: UsePythonVersion@0
  displayName: Use Python 3.8
  inputs:
    versionSpec: '3.8'
    addToPath: true 
# -------------------------------------------------------------------------------------
#Run Pip installer for any prerequisite libraries
# -------------------------------------------------------------------------------------
- bash: 'pip install --target="./.python_packages/lib/site-packages" -r ./requirements.txt'
  displayName: 'Install Application Dependencies'
# -------------------------------------------------------------------------------------
#Archieve all files
# -------------------------------------------------------------------------------------
- task: ArchiveFiles@2
  displayName: 'Archive files'
  inputs:
    rootFolderOrFile: '$(System.DefaultWorkingDirectory)'
    includeRootFolder: false
# -------------------------------------------------------------------------------------
#drop files copied to artifact staging directory
# -------------------------------------------------------------------------------------
- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: drop'
azure azure-functions yaml azure-pipelines azure-pipelines-build-task
1个回答
0
投票

对于 powershell 函数应用程序,您可以简单地使用

AzureFunctionApp@2
任务进行部署。 请参阅此处的文档

这是我用来部署到 powershell 函数应用程序的示例管道,不需要发布管道。

steps:
  - checkout: self

  - task: AzureFunctionApp@2
    inputs:
      azureSubscription: $(subscription)
      appName: ${{ parameters.FunctionApp }}
      resourceGroupName: ${{ parameters.ResourceGroup }}
      slotName: $(slot name)
      package: "$(System.DefaultWorkingDirectory)/function-apps/${{ parameters.FunctionApp }}/"
      appSettings: -WEBSITE_TIME_ZONE "New Zealand Standard Time"
      deploymentMethod: auto

对我来说,

package
输入路径直接指向我的函数应用程序文件夹,如下所示:

如果您希望将其作为发布管道,您还应该能够在发布管道中找到相同的任务,然后您可以将存储库作为工件包含在内,并设置一个触发器以在合并代码时进行部署到你的主/主分支。

© www.soinside.com 2019 - 2024. All rights reserved.