我有訪問,通過一個IBinder通知樞紐Azure的功能,如下所示: -預編譯Azure的功能的的IBinder失敗,「沒有約束力發現屬性」例外
public static async Task Run(string msg, IBinder binder, TraceWriter log)
{
var genericInputMessage = JsonConvert.DeserializeObject<GenericInputMessage>(msg);
string devicetag = "deviceid:" + genericInputMessage.device;
var attribute = new NotificationHubAttribute
{
ConnectionStringSetting = "NotificationHubConnection",
HubName = "NotificationHubName",
TagExpression = devicetag
};
IAsyncCollector<Notification> notifications = binder.Bind<IAsyncCollector<Notification>>(attribute);
...
...
}
這編譯和工程確定當通過Azure門戶完成時。
當我在使用VS2017(版本15.3.3)的預編譯Azure函數中使用相同的代碼並在本地運行它時,我在調用binder.Bind時收到異常。
給出的例外是....
[23/09/2017 16:47:07] A ScriptHost error has occurred
[23/09/2017 16:47:07] Exception while executing function: DataProcessor. Microsoft.Azure.WebJobs.Host: No binding found for attribute 'Microsoft.Azure.WebJobs.NotificationHubAttribute'.
我的預編譯Azure的函數的代碼如下: -
public static async Task Run([EventHubTrigger("EventHubName", Connection = "EventHubConnection")]string msg, IBinder binder, TraceWriter log)
{
var genericInputMessage = JsonConvert.DeserializeObject<GenericInputMessage>(msg);
string devicetag = "deviceid:" + genericInputMessage.device;
var attribute = new NotificationHubAttribute
{
ConnectionStringSetting = "NotificationHubConnection",
HubName = "NotificationHubName",
TagExpression = devicetag
};
IAsyncCollector<Notification> notifications = binder.Bind<IAsyncCollector<Notification>>(attribute);
...
...
}
我使用下面的NuGet包: -
有什麼想法可能會導致這種情況?
根據您的描述,我可以重現我本地端解決此問題。我發現了一個類似的問題(https://github.com/Azure/azure-webjobs-sdk/issues/1295),你可以參考它。 –