The Azure Function used by my blog (https://edi.wang) to send notifications.
This Function sets HTML template and send email notifications to blog administrator or users.
Tools | Alternative |
---|---|
.NET 8.0 SDK | N/A |
Visual Studio 2022 with Azure Development payload | Visual Studio Code |
Azure Key Vault | N/A |
Azure CLI | N/A |
This Function needs a pre-configured email account to send emaills. The account name and server infomations can be configured from environment variables. However, the password must be stored in Azure Key Vault to ensure security. Thus, you have to create an Azure Key Vault first.
You need to setup Azure CLI and login to your Azure subscription first.
Open "\Azure-Deployment\Deploy.ps1"
Parameters example:
-regionName "eastasia"
-rsgName "Moonglade-Test-RSG"
-storageAccountName "moongladeteststorage"
-adminEmail "[email protected]"
-emailDisplayName "Moonglade Notification Test"
-smtpServer "smtp.whatever.com"
-smtpUserName "[email protected]"
-pwdValue "P@ssw0rd"
Build and deploy Moonglade.Notification.sln to the Azure Function that created via Deploy.ps1
Open appsettings.json under your Moonglade instance, add the following settings:
"Email": {
"ApiEndpoint": "https://yourfunctionappurl",
"ApiKey": "<your function key>"
}
For development, create local.settings.json
under "./src/Moonglade.Function.Email", this file defines development time settings. It is by default ignored by git, so you will need to manange it on your own.
Sample local.settings.json
file
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
"moongladestorage": "<storage account connection string>",
"EnableSsl": true,
"SmtpServerPort": 587,
"AdminEmail": "[email protected]",
"EmailDisplayName": "Moonglade Notification Azure Function (local)",
"SmtpServer": "smtp-mail.outlook.com",
"SmtpUserName": "[email protected]",
"EmailAccountPassword": "<smtp password>"
}
}
对于中国用户,我们有一份特定的免责申明。请确保你已经阅读并理解其内容: