Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Azure Webjob自动绑定路径无效?_C#_Azure_Azure Webjobs_Azure Webjobs Triggered - Fatal编程技术网

C# Azure Webjob自动绑定路径无效?

C# Azure Webjob自动绑定路径无效?,c#,azure,azure-webjobs,azure-webjobs-triggered,C#,Azure,Azure Webjobs,Azure Webjobs Triggered,我正在使用Azure Webjobs执行各种任务。我已将我的代码用于发送电子邮件,如下所示: public void ProcessEmailMessage( [QueueTrigger(AzureConstants.queueEmailsToSend)] string message, IBinder binder, ILogger logger) { logger.LogInformation(message); BlobServiceClient blobServiceClient

我正在使用Azure Webjobs执行各种任务。我已将我的代码用于发送电子邮件,如下所示:

public void ProcessEmailMessage(
[QueueTrigger(AzureConstants.queueEmailsToSend)] string message,
IBinder binder, ILogger logger) {
 logger.LogInformation(message);

 BlobServiceClient blobServiceClient = new BlobServiceClient(_appSettings.AzureWebJobsStorage);

 var blobContainer = blobServiceClient.GetBlobContainerClient(_appSettings.DataStoreRoot); //set to "rafflegamesstore"..
 var blobClient = blobContainer.GetBlobClient(message);
 MemoryStream mailBlobstream = new MemoryStream();

 blobClient.DownloadTo(mailBlobstream);
 mailBlobstream.Position = 0;
 MimeMessage messageToSend = MimeMessage.Load(mailBlobstream);

 // the SmtpClient class is the one from Mailkit not the framework!
 using (var emailClient = new SmtpClient())
 {
   //The last parameter here is to use SSL (Which you should!)
   emailClient.Connect(EmailConstants.SmtpServer, EmailConstants.SmtpPort, true);

   //Remove any OAuth functionality as we won't be using it. 
   emailClient.AuthenticationMechanisms.Remove("XOAUTH2");

   emailClient.Authenticate(EmailConstants.SmtpUsername, EmailConstants.SmtpPassword);

   emailClient.Send(messageToSend);
   emailClient.Disconnect(true);
}
我知道现在这很简单,但这是原理的演示。。。 我应该能够将流传递到代码中,而不是所有带有Blob客户端等的shenanignen。因此,将函数签名更改为:

public void ProcessEmailMessage(
[QueueTrigger(AzureConstants.queueEmailsToSend)] string message,
[Blob("rafflegamesstore/{queueTrigger}", FileAccess.Read)] Stream mailBlob,
IBinder binder, ILogger logger)
{
  ...
我认为应该结合容器名称从队列中的消息中读取Blob?(这是“rafflegamestore”.._appSettings.DataStoreRoot也在appSettings.json中设置为该值

"DataStoreRoot": "rafflegamesstore",
这很好,但是当我在上面使用它来尝试获取“mailBlob”时,它失败了,表明BlobPath无效。 我已尝试更改字符串,使斜杠在“”上作为正斜杠,并将其转义为“\”,但均无效

我确信我只是在做一些愚蠢的事情…但我真的很想让这项工作有什么想法