azure 如何从管道部署WebJob

bkhjykvo  于 12个月前  发布在  其他
关注(0)|答案(1)|浏览(146)

我试图为应用服务部署WebJob,与应用服务本身一起。但我发现没有方法有效。所有关于该主题的在线信息似乎都已过时(我找不到Microsoft文档)。
其他一切都正常-我已经验证了工件具有所有正确的文件,在正确的位置。应用程序服务本身上传良好。问题纯粹是WebJob。(为了清晰和安全,我已经编辑了这一点)

trigger:
- development

pool:
  vmImage: windows-latest

variables:
  BuildConfiguration: 'Release'
  AzureSubscription: 'Subscription'

stages:
- stage: Build
  jobs:
  - job: BuildJob
    steps:
    - task: NuGetCommand@2
      inputs:
        command: 'restore'
        restoreSolution: '**/*.sln'
        feedsToUse: 'select'

    - task: VSBuild@1
      inputs:
        solution: '**/API.csproj'
        configuration: '$(BuildConfiguration)'
        msbuildArgs: '/p:OutputPath=$(Build.ArtifactStagingDirectory)/APIOutput'
        platform: 'any cpu'

    - task: VSBuild@1
      inputs:
        solution: '**/WebJob.csproj'
        configuration: '$(BuildConfiguration)'
        msbuildArgs: '/p:OutputPath=$(Build.ArtifactStagingDirectory)/WebJobOutput'
        platform: 'any cpu'

    - task: PublishBuildArtifacts@1
      inputs:
        pathtoPublish: '$(Build.ArtifactStagingDirectory)'
        artifactName: 'drop'
        publishLocation: 'Container'

- stage: Deploy
  dependsOn: Build
  jobs:
  - job: DeployJob
    steps:
    - download: current
      artifact: 'drop'

    - task: AzureRmWebAppDeployment@4
      inputs:
        ConnectionType: 'AzureRM'
        azureSubscription: '$(AzureSubscription)'
        appType: 'webApp'
        WebAppName: 'WebAppName'
        packageForLinux: '$(Pipeline.Workspace)/drop/APIOutput'

    - task: AzureRmWebAppDeployment@4
      inputs:
        ConnectionType: 'AzureRM'
        azureSubscription: '$(AzureSubscription)'
        appType: 'webApp'
        WebAppName: 'WebAppName'
        packageForLinux: '$(Pipeline.Workspace)/drop/WebJobOutput'

字符串

tzcvj98z

tzcvj98z1#

我引用了Rahul Nath的blog,并使用Azure DevOps构建和发布管道Azure Web App + Azure WebJob一起部署,还将其部署在单个构建YAML管道中**
参考我的Github Repository,从Rahul Nath's repository引用我自己的Azure YAML管道,以在单个yaml管道中部署Web App + WebJob。
我在Azure DevOps存储库中推送了这个存储库,然后构建了我的Azure Web应用程序+ Azure WebJob解决方案,如下所示:

My Build YAML pipeline:-

trigger:
- master

pool:
  vmImage: 'windows-latest'

steps:
- task: DotNetCoreCLI@2
  inputs:
    command: 'build'
    projects: '**/*.csproj'
    arguments: '--configuration Release'

- task: DotNetCoreCLI@2
  inputs:
    command: 'publish'
    publishWebProjects: false
    projects: '**/WebJobExample.WebJob.csproj'
    arguments: '--output $(Build.BinariesDirectory)/publish_output/App_Data/jobs/continuous/YoutubeWebJob'
    zipAfterPublish: false
    modifyOutputPath: false

- task: DotNetCoreCLI@2
  inputs:
    command: 'publish'
    publishWebProjects: true
    arguments: '--output $(Build.BinariesDirectory)/publish_output'
    zipAfterPublish: false
    modifyOutputPath: false

- task: ArchiveFiles@2
  inputs:
    rootFolderOrFile: '$(Build.BinariesDirectory)/publish_output'
    includeRootFolder: false
    archiveType: 'zip'
    archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
    replaceExistingArchive: true

- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)'
    ArtifactName: 'drop'
    publishLocation: 'Container'

字符串

输出:-

x1c 0d1x的数据
现在,在你的发布管道中使用构建脚本
在上面的发布管道中选择您的构建工件:-



在阶段中,选择Deploy Azure App Service任务并添加所需的配置:
我创建了一个**.Net 6.0 Windows Azure Web应用程序**,并在我的任务中选择了它,如下所示:



在部署Azure应用服务步骤中,在文件转换步骤中添加了****/appsettings.json**,并保留了其余设置:



添加了一个变量,其中AzureWebJobStorage* 连接字符串是我的存储帐户的连接字符串:-

现在,我保存了管道并创建了一个版本:
发布成功,Azure Web App + Azure Web Job已成功部署:-

输出:-

如果你想在一个YAML管道中运行它,请参考下面的代码:-

trigger:
- master

pool:
  vmImage: 'windows-latest'

steps:
- task: DotNetCoreCLI@2
  inputs:
    command: 'build'
    projects: '**/*.csproj'
    arguments: '--configuration Release'

- task: DotNetCoreCLI@2
  inputs:
    command: 'publish'
    publishWebProjects: false
    projects: '**/WebJobExample.WebJob.csproj'
    arguments: '--output $(Build.BinariesDirectory)/publish_output/App_Data/jobs/continuous/YoutubeWebJob'
    zipAfterPublish: false
    modifyOutputPath: false

- task: DotNetCoreCLI@2
  inputs:
    command: 'publish'
    publishWebProjects: true
    arguments: '--output $(Build.BinariesDirectory)/publish_output'
    zipAfterPublish: false
    modifyOutputPath: false

- task: ArchiveFiles@2
  inputs:
    rootFolderOrFile: '$(Build.BinariesDirectory)/publish_output'
    includeRootFolder: false
    archiveType: 'zip'
    archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
    replaceExistingArchive: true

- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)'
    ArtifactName: 'drop'
    publishLocation: 'Container'

- task: AzureRmWebAppDeployment@4
  inputs:
    ConnectionType: 'AzureRM'
    azureSubscription: 'xx subscription (xxxxxxxxxxxe97cb2a7)'
    appType: 'webApp'
    WebAppName: 'valleywebappjob'
    packageForLinux: '$(Agent.BuildDirectory)/**/*.zip'
    WebConfigParameters: '**/appsettings.json'

输出:-

相关问题