发布 Azure 函数不会在服务总线消息上触发

Published Azure Function doesnt trigger on Service bus message

我在发布(来自 VS 代码)Azure 函数时遇到问题,该函数应该在将消息添加到队列时触发,不幸的是,添加消息后什么也没有发生,函数执行计数始终为 0,记录是空的。一切都在本地工作,我真的不知道如何才能完成这项工作。

配置变量已填充,包含:

这是我的 yaml 文件:

- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: AzureAppServiceSettings@1
  displayName: Update App Service Settings
  inputs:
    ConnectedServiceName: $(ServiceConnection)
    resourceGroupName: $(ResourceGroup)
    appName: $(WebApp)
    slotName: 'production'
    appSettings: |
      [
        {
          "name": "Values:test",
          "value": "$(test)",
          "slotSetting": false
        }
     ]
- task: AzureAppServiceSettings@1
  displayName: Update Azure Function Settings
  inputs:
    azureSubscription: $(ServiceConnection)
    resourceGroupName: $(ResourceGroup)
    appName: $(FunctionApp)
    slotName: 'production'
    appSettings: |
      [
        {
          "name": "test2",
          "value": "$(test2)",
          "slotSetting": false
        }
      ]
- task: AzureRmWebAppDeployment@4
  inputs:
    ConnectionType: 'AzureRM'
    azureSubscription: $(ServiceConnection)
    appType: 'webApp'
    WebAppName: $(WebApp)
    deployToSlotOrASE: true
    ResourceGroupName: $(ResourceGroup)
    SlotName: 'production'
    packageForLinux: '$(Build.ArtifactStagingDirectory)/**/*.zip'

- task: AzureRmWebAppDeployment@4
  displayName: Deploy to FunctionApp
  inputs:
    ConnectionType: "AzureRM"
    azureSubscription: $(ServiceConnection)
    appType: 'functionApp'
    WebAppName: $(FunctionApp)
    deployToSlotOrASE: true
    ResourceGroupName: $(ResourceGroup)
    SlotName: 'production'
    packageForLinux: '$(Build.ArtifactStagingDirectory)/**/*.zip'

函数代码:

        [FunctionName(TopicBeginFunction)]
        public async Task ConsumeStatusMessageFromQueue(
           [ServiceBusTrigger("%TopicBegin%", "%SubscriptionBegin%", Connection = "ServiceBusConnectionString")]
        Message topicMessage, CancellationToken cancellationToken, ILogger logger)
        {
            logger.LogInformation("Started");
            try
            {

提前感谢您的帮助!

感谢@Krzysztof的宝贵建议, 用于解决上述问题,因为您已确认 解决方法 作为答案发布以帮助其他社区成员解决类似问题。

  • WEBSITE_RUN_FROM_PACKAGE 添加到 0 而不是使用 1 后问题已解决。

类似问题请参考以下链接:-