2017-10-04 97 views
-1

有人能告诉我SendGrid是否可用于不使用.net核心的Azure工作者角色项目中?了解使用sendgrid进行通知的更好方法也很好。工作者角色或网络工作或Azure功能?在Azure工作者角色中使用SendGrid

虽然试图在一个项目,该项目是不.NET的核心使用它,我得到以下错误而创建sendgrid客户端:

“‘System.IO.FileNotFoundException’在SendGrid.dll”

感谢

-Ravi

+0

当试图使用什么?尝试提供一段代码和一些上下文,不要让我们挂起。 – evilSnobu

回答

0

谁能告诉我,如果SendGrid可以在不使用.NET核心Azure的辅助角色项目中使用?

它应该在Azure辅助角色中工作。我也做了测试,它在我身边正常工作。以下是演示代码。

private async Task RunAsync(CancellationToken cancellationToken) 
{ 
      var apiKey = "sendgrid APIkey"; 
      var client = new SendGridClient(apiKey); 

      // TODO: Replace the following with your own logic. 
      while (!cancellationToken.IsCancellationRequested) 
      { 
       Trace.TraceInformation("Working"); 

       var msg = new SendGridMessage 
       { 
        From = new EmailAddress("send email", "Sunguiguan"), 
        Subject = "Hello World from the SendGrid CSharp SDK!", 
        PlainTextContent = "Hello, Email!", 
        HtmlContent = "<strong>Hello, Email!</strong>" 
       }; 
       msg.AddTo(new EmailAddress("another email", "test user")); 
       client.SendEmailAsync(msg, cancellationToken).Wait(cancellationToken); 

       await Task.Delay(1000*60, cancellationToken); 
      } 
    } 

enter image description here

这也将是很好的知道什么是使用sendgrid的通知更好。工作者角色或网络工作或Azure功能?

所有这些服务都可以使用sendgrid进行通知。这取决于你想要的东西。我们可以参考Azure Webjobs vs Azure Functions : How to chooseAzure App Service, Virtual Machines, Service Fabric, and Cloud Services comparison以获得更多信息。

相关问题