Update on 25 June – 2 (SOLVED)
How could I have been so foolish…
I set up a secret generic and modified the deployment.yaml to assign variables. And it worked…
To sum up my questions, all were caused by not setting up the environment variables properly.
Update on 25 June – 2
After the 403 Forbidden problem with the Web APP has been fixed, however, I am now encountering the same problem in AKS. I want the containers in AKS to send logs to the same custom table as the Web APP, but they are showing the same error in the error message.
Update on 25 June – 1
I have successfully sent logs to a custom table in Log Analytics.
This was after I realized I had missed setting up the environment variables, as shown in the screenshot below.
After setting up the environment variables, it works to send logs to custom table. 🙂
I have published a containerized Web App on Azure running Linux OS, coded in C# .NET.
And I want to send my app logs to custom table in Azure Log Analytics.
Therefore, I follow the tutorials on Tutorial: Send data to Azure Monitor using Logs ingestion API (Resource Manager templates) and Sample code to send data to Azure Monitor using Logs ingestion API to set-up Azure environment (DCR, DCE, creating a new table, App registration) and write .NET code to try send data to my custom table.
Despite numerous attempts, I consistently received a 403 (Forbidden) error code. Even though I have waited over 30 minutes (according to troubleshooting), the issue persists.
Error messages from Azure Log stream as belowed:
Upload failed with Exception The authentication token provided does not have access to ingest data for the data collection rule with immutable Id ‘dcr-‘.
Status: 403 (Forbidden)
ErrorCode: OperationFailed
Content:
{"error":{"code":"OperationFailed","message":"The authentication token provided does not have access to ingest data for the data collection rule with immutable Id ‘dcr-‘."}}
If anyone has experienced similar issues or has any suggestions, I would be very appreciated!
2
Answers
Thanks to Pravallika for taking the time to replicate my case. I figured out the solution after carefully reviewing the documentation again. Not only Web APP but also AKS, all questions are about not setting up the environment variables.
。For the Web APP
The key point is not to overlook setting the Environment variables
。For AKS
Step 1. Create Kubernetes Secret
Step 2. Use Secret in the setting of Pod
Step 3. Apply the deployment.
Everything is now perfectly set up.
I have followed the MSDoc to configure the prerequisites required to send the data to Azure monitor logs using log ingestion API.
Provide access to the registered application and your user account from the DCR as mentioned in MSDOC.
Navigate to your
Data Collection Rule(DCR) instance=>Access Control(IAM)=>Add Role Assignment=>
Select Monitoring Metrics Publisher role=> Select User, Group or Service principal=> Select your Application and the user account.I am able to run the code and got the expected response.
Code Snippet:
Console Response:
Logs Uploaded to the Custom Table in Log Analytics Workspace: