Hello MohdFhG,
welcome to this moderated Azure community forum.
This blog post explaining how to connect an actual device and custom OPC-UA server describes the steps to create a connect asset.
Yes, managing the key is cumbersome and easy to do it wrong.
That is why I introduce that dummy asset endpoint because it is not possible to add credentials via code and have it synchronized to the edge as a 'Kubernetes secret'.
Keep an eye that the name of the secret (like opcuassetpassword) is only used within the Azure Keyvault. in the CLI commands the generic 'password' must be used. This can be seen in the properties of the dummy endpoint using the k9s tool.
If the response helped, do "Accept Answer". If it doesn't work, please let us know the progress. All community members with similar issues will benefit by doing so. Your contribution is highly appreciated.