Moonglade.ContentSecurity

December 1, 2025 ยท View on GitHub

The Azure Function used by my blog (https://edi.wang) for filtering harmful text in order to live in China.

This Function filter harmful text by Azure AI Content Safety

Get Started

ToolsAlternative
.NET 10.0 SDKN/A
Visual Studio 2026 with Azure Development payloadVisual Studio Code
Azure Key VaultN/A
Azure CLIN/A

Deployment

IMPORTANT: Please use release branch for deployment!!!

Build and deploy the project to your Azure subscription.

Recommendations:

  • Enable 64 bit worker process in Azure Function App settings.
  • Enable Always On in Azure Function App settings.
  • Enable Application Insights in Azure Function App settings.
  • Use App Service Plan hosting model for better performance.

Azure Moderation

Pre-requisite: create an Azure AI Content Safety resource in Azure Portal, and get the endpoint and key.

Once deployed to Azure, set the following environment variables in Azure Portal (Configuration blade) or Azure CLI:

Development and Debugging

For development, create local.settings.json under "./src/", 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",
    "Keywords": "example|harmful|words",
    "Endpoint": "https://<your resource name>.cognitiveservices.azure.com/",
    "OcpApimSubscriptionKey": "<your key>"
  }
}