I'm working with Azure Function isolated process .net 6.
I have an issue to work with the service bus and service bus trigger.
If in-process I will declare like this
public async Task<ActionResult> Run([HttpTrigger(AuthorizationLevel.Function, "post", Route = null)]HttpRequest req, ILogger log, ExecutionContext context,
[ServiceBus("mail-sender", Connection = "ServiceBusConnection")] IAsyncCollector<dynamic> outgoingMessage)
{
... outgoingMessage.Send(mymessage);...
}
And then I will have another service bus trigger azure function to process the message like this
public void Run([ServiceBusTrigger("mail-sender", Connection = "ServiceBusConnection")]string myQueueItem, ILogger log)
{
try
{
var mailHost = Environment.GetEnvironmentVariable("MAIL_HOST") ?? "smtp.sendgrid.net";
var mailPort = Convert.ToInt32(Environment.GetEnvironmentVariable("MAIL_PORT") ?? "587");
var mailUsername = Environment.GetEnvironmentVariable("MAIL_USERNAME") ?? "apikey";
var mailPassword = Environment.GetEnvironmentVariable("MAIL_PASSWORD") ?? "8755faf7-78c9-4389-b3a5-f1578953bc00";
var ssl = Convert.ToBoolean(Environment.GetEnvironmentVariable("MAIL_SSL") ?? "false");
using (var mailHelpers = new MailHelpers(mailHost, mailPort, mailUsername, mailPassword, ssl))
{
var mail = JsonConvert.DeserializeObject<MailViewModel>(myQueueItem);
mailHelpers.Send(mail);
}
}
catch (Exception ex)
{
log.LogError(ex, "Error during sending email.");
}
}
How can I achieve that in the azure function isolated process?
Please help me to give example detail and the package's dependencies if any.
Many thanks
===========================
BTW, I have declare TimerTrigger azure function, it uses https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.Timer It can trigger the task to run, but I cannot debug it? I'm not sure why?
public async Task<DispatchedMessages> Run([TimerTrigger("* * * * * *")] MyInfo myTimer)
{
try
{...}
}