问题
I am trying to associate an existing WebJob (created with Azure WebJob template of net461) project, with an existing Web Application, by following https://docs.microsoft.com/en-us/azure/app-service/webjobs-dotnet-deploy-vs link.
However,
Problem 1 : Visual Studio shows me the "Add->Existing Project as Azure WebJob" the first time, then when I click on that menu, it throws an error saying "command is not applicable for the selected project". After that, it never shows that menu, unless I restart the VS again.
Problem 2 : On the other hand, my independent WebJob project, even after getting published to Azure through VS in my Web Application (to wwwroot/app_data/jobs/continuous/WebJob), WeJob is not getting triggered or recognized by my Web Application. But, when I execute the EXE in the published location, it executes successfully.
Problem 3 : I followed the answer in Deploy console webjob app to azure App service containing a webapi using azure devops pipelines link to release my WebJob from Azure Pipeline. But, that is creating an Artifact directory under wwwroot/app_data/jobs/continuous/WebJob and pushing the ZIP file, instead of EXE. As my project is in net461, my build tasks are not dotnetcore. So, I am not getting exactly same UI as in the link.
Is there any latest documentation available to achieve this?
YML File;
# ASP.NET Core (.NET Framework)
# Build and test ASP.NET Core projects targeting the full .NET Framework.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core
trigger:
- master
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
inputs:
restoreSolution: '$(solution)'
- task: VSBuild@1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebJob.zip" /p:DeployIisAppPath="Default Web Site"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: VSTest@2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'AzureWebJobArtifact'
publishLocation: 'Container'
My deploy task has;
Connection Type = Azure Resource Manager
App Service Type = Web App on Windows
Package or Folder = $(System.DefaultWorkingDirectory)/AzureWebJobArtifact
Deployment Method = ''
EDIT :
After changing Build & Publish Artifact tasks in YML as below, it creates Folder "AzureWebJobArtifact" under WEBJOB_ROOT_PATH (wwwroot/app_data/jobs/continuous/WebJob) and deploying only necessary executables.
- task: VSBuild@1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:OutDir=$(System.DefaultWorkingDirectory) /p:DeployIisAppPath="Default Web Site"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(System.DefaultWorkingDirectory)\AzureWebJob\obj\Release\net461'
ArtifactName: 'AzureWebJobArtifact'
publishLocation: 'Container'
I just want my WebJob to be triggered/continuous after publishing.
来源:https://stackoverflow.com/questions/58360789/associating-webjob-with-web-app-in-visual-studio-azure-pipeline