Skip to content

Content security Azure Function for filtering harmful text

License

Notifications You must be signed in to change notification settings

EdiWang/Moonglade.ContentSecurity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

93 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Moonglade.ContentSecurity

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

Tools Alternative
.NET 10.0 SDK N/A
Visual Studio 2026 with Azure Development payload Visual Studio Code
Azure Key Vault N/A
Azure CLI N/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>"
  }
}

About

Content security Azure Function for filtering harmful text

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Contributors