The blog system for https://edi.wang. Written in C# on .NET Core and runs on Microsoft Azure.
Basic: Post, Comment, Category, Archive, Tag, Page, Friendlink
Misc: Pingback, RSS/Atom/OPML, Open Search, Reader View
Tools | Alternative |
---|---|
.NET Core 3.1 SDK | N/A |
Visual Studio 2019 | Visual Studio Code |
Azure SQL Database | SQL Server 2019 / LocalDB (Dev Only) |
If you would like to deploy Moonglade to Azure and use Azure services as much as possible just like my blog, you can use the automation deployment script
/Azure-Deployment/Deploy.ps1
to prepare a full Azure environment before deploying code.
Create an SQL Server 2019 LocalDB database. e.g. moonglade-dev
Create an Azure SQL Database or a SQL Server 2019 database. e.g. moonglade-production
Update the connection string "MoongladeDatabase" in appsettings.[env].json according to your database configuration.
Example:
"ConnectionStrings": {
"MoongladeDatabase": "Server=(localdb)\\MSSQLLocalDB;Database=moonglade-dev;Trusted_Connection=True;"
}
Set environment variable: ConnectionStrings__MoongladeDatabase
to your connection string. If you are deploying to Azure App Service, you can set the connection string in the Configuration blade.
Build and run Moonglade.sln
- Default Admin Username: admin
- Default Admin Password: admin123
Create an "appsettings.Development.json" under "src\Moonglade.Web", this file defines development time settings such as accounts, db connections, keys, etc. It is by default ignored by git, so you will need to manange it on your own.
Below section discuss system settings in appsettings.[env].json. For blog settings, please use "/admin/settings" UI.
Configure how to sign in to admin portal.
Register an App in Azure Active Directory
- Set Redirection URI to "https://yourdomain/signin-oidc"
- For local debugging, add URL to https://localhost:1055/signin-oidc
- Check
ID Tokens
checkbox under 'Advanced settings'. - Copy "appId" to set as AzureAd:ClientId in appsettings.[env].json file
"Authentication": {
"Provider": "AzureAD",
"AzureAd": {
"Domain": "{YOUR-VALUE}",
"TenantId": "{YOUR-VALUE}",
"ClientId": "{YOUR-VALUE}",
}
}
Set Authentication:Provider to "Local" and assign a pair of username and password.
Currently password is not encrypted, use it at your own risk.
"Authentication": {
"Provider": "Local",
"Local": {
"Username": "{YOUR-VALUE}",
"Password": "{YOUR-VALUE}",
}
}
AppSettings:ImageStorage controls how blog post images are stored. There are 2 built-in options:
Azure Blob Storage (Preferred)
You need to create an Azure Blob Storage with container level permission.
"Provider": "azurestorage"
"AzureStorageSettings": {
"ConnectionString": "YOUR CONNECTION STRING",
"ContainerName": "YOUR CONTAINER NAME"
}
"Provider": "filesystem",
"FileSystemSettings": {
"Path": "${basedir}\\UploadedImages"
}
The Path can be relative or absolute. "${basedir}" represents the website's current directory. Storing images files under website directory is NOT recommended.
If GetImageByCDNRedirect is set to true, the blog will get images from client browser using a 302 redirect, not by fetching images in backend and put into memory cache. This is especially useful when you have a CDN for your image resources, like what I did on Azure.
Note: Azure CDN is extremely slow under China Telecom and China Mobile network, if you are operating in China, please use a local CDN provider.
"CDNSettings": {
"GetImageByCDNRedirect": true,
"CDNEndpoint": "https://ews.azureedge.net/ediwang-images"
}
If you need email notification for new comments, new replies and pingbacks, you have to setup the Moonglade.Notification API first.
See https://github.com/EdiWang/Moonglade.Notification for instructions
Set values in AppSettings:
"Notification": {
"Enabled": true,
"ApiEndpoint": "{PROD-ENV-VARIABLE}",
"ApiKey": "{PROD-ENV-VARIABLE}"
}
Key | Description |
---|---|
Editor | HTML / Markdown |
CaptchaSettings:ImageWidth | Pixel Width of Captcha Image |
CaptchaSettings.ImageHeight | Pixel Height of Captcha Image |
PostAbstractWords | How may words to show in post list abstract |
ImageCacheSlidingExpirationMinutes | Time for cached images to expire |
EnforceHttps | Force website use HTTPS |
AllowScriptsInCustomPage | Allow JavaScript in Page content or not |
EnableAudit | Enable Audit Log or not |
It depends. If the database schema is same for a higer version, then the system can be deployed and override old files without problem.
No, the system design does not couple with Azure, but the blog works best on Azure. Every part of the system, like Authentication and Image Storage, can be configured to use non-Azure options.
Below open source projects are reusable components (NuGet packages) used in my blog, and they can be used in other websites as well.