Terraform external module fails deployment

Hi all,
I’ve been fighting with strange issue that I have never experienced before. I am trying to deploy Azure Function App, App Service and App Service Plan. I have created modules for all the resources and in all cases I am experiencing issues when a pipeline runs the terraform apply. The issue states that managed identity has no permissions for action Microsoft.Web/site/read in case of App Service, and Microsoft.Web/serverFarms/read in case of Function App. The user assigned managed identity that a pipeline agent uses has all the permissions which was verified multiple times but still the issue persists.
For test I copied the code from the module and pasted it into my provisioner root module as a resource block, and it works with no issues, and deploys resources successfully.
I am using azurerm provider version 4.35.0 but also tested 4.30.0 and 4.20.0 and no change. Still the same behavior.
Anybody here experienced this sort of issue before?