创建了一个 Azure Function,它是在 Visual Studio 中触发的服务总线,并从 Visual Studio 发布到 Azure。
每当消息进入队列时,手动运行时该函数都会在本地正常运行。但期望的是当消息在队列中时该函数应该自动触发。
我只是手动添加一条新消息,并查看该函数是否自动触发的日志,但事实并非如此。当我检查 Application Insight 时,我发现以下错误日志
函数“ProcessVideos”的侦听器无法启动。服务总线帐户连接字符串“连接”不存在。确保它是已定义的应用程序设置。*”
local.settings.json设置服务总线连接字符串的代码。
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"connection": "Endpoint=sb://videoupload10000.servicebus.windows.net/;SharedAccessKeyName=Listen;SharedAccessKey=80n8a0MCmh+3UZN4+4B7gDy4gp3hKCxfDI/9urDmaP8=;"
}
}
Run Code Online (Sandbox Code Playgroud)
实际功能的代码。
using System;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using Azure.Messaging.ServiceBus;
using Azure.Storage.Blobs;
using Azure.Storage.Blobs.Models;
using Microsoft.Azure.Cosmos;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging;
namespace ReceiveMessages
{
public static class Process
{
private static string blob_connection_string = "DefaultEndpointsProtocol=https;AccountName=videostorage1000;AccountKey=y6CVtXafqKuShZuv6BMbVj9DrymzVdNDpjDVxp6hZMvuRRjcCz/i8TrOGfM5T/JCvfG33sY3xqqW+ASt3p6V+Q==;EndpointSuffix=core.windows.net";
private static string source_container_name = "unprocessed";
private static string destination_container_name = "processed"; …Run Code Online (Sandbox Code Playgroud)