This demonstration project shows how you can utilise Microsoft.Extensions.Compliance.Redaction extensions to redact sensitive information from your Azure Function logs.
There is a bit of work involved to get this working and it is currently only supported with .NET 8 and the Azure Functions Isolated Worker model (which will be the only supported model from .NET 9 onwards).
Requirements to get going with the solution:
- Visual Studio Code.
- Azure Core Functions Tools.
- .NET 8 SDK.
- Application Insights Instance (optional, but you will need to remove code if you don't want to use it).
To run this sample locally use a local.settings.json
similar to the one shown below.
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
"APPLICATIONINSIGHTS_CONNECTION_STRING": "InstrumentationKey={YOUR_KEY};IngestionEndpoint=https://{YOUR_ENDPOINT}.applicationinsights.azure.com/;LiveEndpoint=https://{YOUR_ENDPOINT}.livediagnostics.monitor.azure.com/",
"EnableRedaction": "false"
}
}