【发布时间】:2019-05-04 20:23:12
【问题描述】:
我创建了一个控制台用于向 Azure 服务总线主题发送消息,并创建了一个服务总线主题触发器。在本地它工作正常,但是在 azure 中部署相同的功能后,相同的代码不起作用。我是 Azure 的新手,请帮助解决问题并在下面获取我的代码详细信息。
host.json
{
"version": "2.0",
"aggregator": {
"batchSize": 1000,
"flushTimeout": "00:00:30"
},
"extensions": {
"cosmosDb": {},
"durableTask": {},
"eventHubs": {},
"http": {},
"queues": {},
"sendGrid": {},
"serviceBus": {}
},
"functions": [],
"functionTimeout": "00:05:00",
"healthMonitor": {
"enabled": true,
"healthCheckInterval": "00:00:10",
"healthCheckWindow": "00:02:00",
"healthCheckThreshold": 6,
"counterThreshold": 0.80
},
"logging": {
"fileLoggingMode": "debugOnly",
"logLevel": {
"Function.MyFunction": "Information",
"default": "None"
},
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"maxTelemetryItemsPerSecond": 5
}
}
},
"singleton": {
"lockPeriod": "00:00:15",
"listenerLockPeriod": "00:01:00",
"listenerLockRecoveryPollingInterval": "00:01:00",
"lockAcquisitionTimeout": "00:01:00",
"lockAcquisitionPollingInterval": "00:00:03"
},
"watchDirectories": [ "Shared", "Test" ]
}
local.setting.json
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "DefaultEndpointsProtocol=https;....",
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"MyConnection": "Endpoint=sb://...."
}
}
又试了一个
{
"IsEncrypted": false,
"Values": {
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"MyConnection": "Endpoint=sb://",
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"AzureWebJobsDashboard": "UseDevelopmentStorage=true"
},
"Host": {
"LocalHttpPort": 7077
}
}
功能代码:
[FunctionName("Function1")]
public static void Run([ServiceBusTrigger("*****", "*****", Connection = "MyConnection")]string mySbMsg, ILogger log)
{
log.LogInformation($"C# ServiceBus topic trigger function processed message: {mySbMsg}");
}
MyConnection--> 在这里传递服务总线连接字符串。
在本地我们可以获得调试点,如果我们尝试在另一台服务器上单独运行相同的功能,它不会监听请求。我在哪里做错了?帮我解决这个问题!
更新 此外,在发布 Azure 总线时,单击 Visual Studio 中的应用程序设置。然后,您还需要将连接字符串提供给远程。那么它肯定会起作用!
【问题讨论】:
-
您无权将数据保存在服务器 c 盘上。所有数据必须保存在用户有权写入的客户端文件系统中。
-
我需要在哪里授予权限@jdwengspan>
-
你永远不想在服务器上保存数据。数据始终在客户端(用户)文件系统上。
标签: c# azure azure-functions azureservicebus azure-servicebus-topics