@Lucas Harskamp
I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this!
Error Message:
Unhandled exception. Azure.RequestFailedException: The user, group or application 'appid=XXXX;oid=XXXX;iss=https://sts.windows.net/XXXX does not have secrets get permission on key vault 'XXXKeyVault;location=XXX'.
Solution:
After setting everything up correctly, you retured in the morning and noticed that everything was working as expected.
Curiously enough... I set everything correctly. When I turned it on again this morning, without having changed anything, now it suddenly allowed me to do everything. Maybe there was a backend delay in Azure?
When it comes to assigning RBAC roles, please keep in mind that Azure Resource Manager sometimes caches configurations and data to improve performance.
When you assign roles or remove role assignments, it can take up to 10 minutes for changes to take effect. If you're using the Azure portal, Azure PowerShell, or Azure CLI, you can force a refresh of your role assignment changes by signing out and signing in. If you're making role assignment changes with REST API calls, you can force a refresh by refreshing your access token.
Note: It can take several hours for changes to a managed identity's group or role membership to take effect.
If I missed anything please let me know and I'd be happy to add it to my answer, or feel free to comment below with any additional information.
I hope this helps!
If you have any other questions, please let me know. Thank you again for your time and patience throughout this issue.