EdiWang / Moonglade.Email

The Azure Function used by my blog (https://edi.wang) to send email notifications
MIT License
8 stars 6 forks source link

Get mailConfiguration failed when using smtp #39

Open QyQj opened 1 week ago

QyQj commented 1 week ago

RunningDirectory Error

When call TestEmail and QueueProcessor , the function throw error

[Error]   Configuration file for EmailHelper is not present.

And I add some log for the runningDirectory which get from Environment.CurrentDirectory, the log show this

[Information]   runningDirectory = C:\local\Temp\functions\standby\wwwroot

I used the console of function app but can not find the directory logged,

and I tried to use AppContext.BaseDirectory instead of Environment.CurrentDirectory,

the log show this directory and the function works well

[Information]   runningDirectory = C:\home\site\wwwroot\

I'm new to azure so I don't know whether the azure function running enviroment is different from common windows

But I guess that the error directory was used by IIS or Azure

I created the function manually because the deploy script doesn't work, so our enviroment maybe different

DeploySMTP.ps1 doesn't work

In my case, after create the keyvault, the permission mode of it was in Azure RBAC by default so the script can not create a secret and then authorize the function app to access it.

And the script doesn't add the moongladestorage environment variable which will be used at the Enqueue function to insert message into storage queue.

EdiWang commented 6 days ago

Hi @QyQj

What's the OS of your Azure Function's App Service Plan? I only deployed to Windows workers. Environment.CurrentDirectory cloud be working differently on Linux plans.

DeploySMTP.ps1 is outdated, I will update the script before end of this year.

For Azure deployments, Azure Communication Service is now preferred, it won't require an SMTP server.

QyQj commented 5 days ago

It's windows, but the pricing plan is Consumption(Serverless)