Hello Rutger Koperdraad
1. Validate Service Principal Permissions
Ensure the service principal (App Registration) used by the failing App Services has same permissions as working app services.
2. Check App Configuration for Auth
Compare the App Settings of working vs non-working App Services:
- TENANT_ID
- CLIENT_ID
- CLIENT_SECRET
- DCR_IMMUTABLE_ID
- LOGS_INGESTION_ENDPOINT
- TABLE_NAME
Make sure there are no typos, whitespace issues, or missing values.
3. Verify Token Acquisition
Ensure the token is being acquired correctly using the service principal:
POST https://login.microsoftonline.com/<tenant-id>/oauth2/v2.0/token
Content-Type: application/x-www-form-urlencoded
client_id=<client-id>
client_secret=<client-secret>
scope=https://monitor.azure.com/.default
grant_type=client_credentials
Check if the token request is succeeding in the failing apps. You can log the token response or error.
4. Inspect Logs Ingestion API Call
Enable verbose logging in your custom Serilog sink to capture:
- The exact request payload
- The response status code and body
- Any exceptions or retries
Look for:
- 401 Unauthorized → likely token or permission issue
- 403 Forbidden → access denied to DCR or workspace
- 400 Bad Request → malformed payload or wrong table name
- 404 Not Found → incorrect DCR or endpoint
5. Test the Service Principal Manually
From your local machine or Azure Cloud Shell, try sending a test payload using the same service principal credentials. This can help isolate whether the issue is in the app service environment or the credentials/config.
6. Check DCR Association
Ensure that the Data Collection Rule used is adequately set up and includes the custom log table (Serilog_CL). If you’re using any transformations in the DCR, verify that they're correctly configured.
Even with service principal auth, the DCR must be associated with the App Service resource (or its resource group/subscription).
az monitor data-collection rule association list --resource <app-service-resource-id>
If the association is missing, create it:
az monitor data-collection rule association create \
--name <association-name> \
--resource <app-service-resource-id> \
--rule <dcr-resource-id>
7.Network and Firewall Issues
Confirm that there are no firewall or network configuration issues preventing logs from being sent. This includes validating if the needed outbound traffic to Azure Monitor is allowed.
Use the Kudu Console (https://<app-name>.scm.azurewebsites.net/DebugConsole)
to Test outbound connectivity to the Logs Ingestion API endpoint. Run a simple PowerShell or curl command to simulate the ingestion call.
Please let me know if you face any challenge here, I can help you to resolve this issue further
If the comment was helpful, please click "Upvote"