Hello @SeyedibrahimMuhamedsalihETWCogniza-3751, my sincere apologies for the delay. I will try and address the questions as mentioned above in order.
I find that cosmosdb logs have correlation id (under Azure Diagnostics & metric tables) but how to populate it via sdk I need assistance?
As mentioned in the Stackoverflow post made by you, I think this is not possible.
from log analytics I cant able to access custom log message of azure functions?
If you have followed this documentation to configure log analytics for your function app, the custom logs do get populated, but there is some delay when you initially configure it (I had to wait aprox. 30-40 mins) before the logs started appearing after this logs were uploaded instantly. You can find the custom user generated logs under the Category - "Function.<HttpTriggerName>.User". In application insights these type of logs are generated as trace item type.
FunctionAppLogs does not have correlation id how can I correlate functions log with apim and cosmosdb?
Yes you are correct Function App logs in Log analytics do not have correlation_id, alternatively you can leverage Application insights for correlating the logs. According to the documentation Application Insights supports distributed telemetry correlation. To associate telemetry with a logical operation, every telemetry item has a context field called operation_Id. This identifier is shared by every telemetry item in the distributed trace.
For Http triggered Function App some of the distributed tracings are tracked automatically. Using the operation_id mentioned above you can the find the logs related to APIM and Cosmos Db under "dependency" item type. For configuration of application insights you can follow the documentation for Function App and APIM.
Please let me know if there are any concerns, I will be glad to continue with our discussion.