J'ai une fonction Azure qui accède à un centre de notification par un IBinder, comme suit: -Fonction Azure pré-compilé avec IBinder échoue avec « Aucune liaison trouvé pour l'attribut » exception
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);
...
...
}
Ceci compile et fonctionne bien lorsque cela est fait via le portail Azure.
Lorsque j'utilise le même code dans une fonction Azure précompilée à l'aide de VS2017 (version 15.3.3) et l'exécute localement, j'obtiens une exception lors de l'appel à classeur.Bind.
L'exception est donnée ....
[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'.
Le code de ma fonction Azure pré-compilé est la suivante: -
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);
...
...
}
J'utilise les paquets NuGet suivants: -
Des idées sur ce qui pourrait être à l'origine de cela?
D'après votre description, je pourrais reproduire ce problème de mon côté local. J'ai trouvé un [problème] similaire (https://github.com/Azure/azure-webjobs-sdk/issues/1295), vous pouvez vous y référer. –