This repo demonstrates how to store a secret from an azure resource (application insights) to key vault using terraform.
For more info, please refer to this blog article : https://alysha-arshad.medium.com/deploying-key-vault-with-secrets-using-terraform-to-azure-51c4e1dfe390?source=friends_link&sk=5e94d90916ac09c3a16daa8a17a94e5c