'Getting object id from enterprise application "Azure Key Vault"with Terraform does not work

when I try to get the object id of the existing Azure enterprise application "Azure Key Vault" with:

az ad sp show --id cfa8b339-82a2-471a-a3c9-0fc0be7a4093

(See also https://docs.microsoft.com/en-us/azure/key-vault/secrets/overview-storage-keys#service-principal-application-id ) It works! I get the correct object id. But when I try to get it with Terraform:

data "azuread_application" "example" {
  application_id = "cfa8b339-82a2-471a-a3c9-0fc0be7a4093"
}

output "key_vault_object_id" {
  value = data.azuread_application.example.object_id
  sensitive = false
}

It does not work. I get:

No applications found matching filter: "appId eq 'cfa8b339-82a2-471a-a3c9-0fc0be7a4093'"

Does someone has an idea?

Thanks in advance!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source