{"action":"created","issue":{"url":"https://api.github.com/repos/terraform-providers/terraform-provider-azurerm/issues/1844","repository_url":"https://api.github.com/repos/terraform-providers/terraform-provider-azurerm","labels_url":"https://api.github.com/repos/terraform-providers/terraform-provider-azurerm/issues/1844/labels{/name}","comments_url":"https://api.github.com/repos/terraform-providers/terraform-provider-azurerm/issues/1844/comments","events_url":"https://api.github.com/repos/terraform-providers/terraform-provider-azurerm/issues/1844/events","html_url":"https://github.com/terraform-providers/terraform-provider-azurerm/issues/1844","id":355589182,"node_id":"MDU6SXNzdWUzNTU1ODkxODI=","number":1844,"title":"azurerm_azuread_service_principal does not always find a Service Principal","user":{"login":"steve-hawkins","id":7125740,"node_id":"MDQ6VXNlcjcxMjU3NDA=","avatar_url":"https://avatars0.githubusercontent.com/u/7125740?v=4","gravatar_id":"","url":"https://api.github.com/users/steve-hawkins","html_url":"https://github.com/steve-hawkins","followers_url":"https://api.github.com/users/steve-hawkins/followers","following_url":"https://api.github.com/users/steve-hawkins/following{/other_user}","gists_url":"https://api.github.com/users/steve-hawkins/gists{/gist_id}","starred_url":"https://api.github.com/users/steve-hawkins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/steve-hawkins/subscriptions","organizations_url":"https://api.github.com/users/steve-hawkins/orgs","repos_url":"https://api.github.com/users/steve-hawkins/repos","events_url":"https://api.github.com/users/steve-hawkins/events{/privacy}","received_events_url":"https://api.github.com/users/steve-hawkins/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-08-30T13:36:56Z","updated_at":"2018-08-30T19:28:43Z","closed_at":null,"author_association":"NONE","body":"### Community Note\r\n\r\n* Please vote on this issue by adding a 👍 [reaction](https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) to the original issue to help the community and maintainers prioritize this request\r\n* Please do not leave \"+1\" or \"me too\" comments, they generate extra noise for issue followers and do not help prioritize the request\r\n* If you are interested in working on this issue or have submitted a pull request, please leave a comment\r\n\r\n### Terraform Version\r\n\r\nTerraform v0.11.8\r\n+ provider.azurerm v1.13.0\r\n\r\n### Affected Resource(s)\r\n\r\nData Source: azurerm_azuread_service_principal\r\n\r\n### Terraform Configuration Files\r\n\r\n```\r\nvariable \"application_name\" {\r\n  type = \"string\"\r\n}\r\n\r\nresource \"azurerm_azuread_application\" \"test\" {\r\n  name = \"${var.application_name}\"\r\n}\r\n\r\nresource \"azurerm_azuread_service_principal\" \"test\" {\r\n  application_id = \"${azurerm_azuread_application.test.application_id}\"\r\n}\r\n\r\ndata \"azurerm_azuread_service_principal\" \"test\" {\r\n  application_id = \"${azurerm_azuread_application.test.application_id}\"\r\n}\r\n\r\noutput \"spn_object_id\" {\r\n  value = \"${data.azurerm_azuread_service_principal.test.id}\"\r\n}\r\n```\r\n\r\n### Debug Output\r\n\r\n[gist](https://gist.github.com/steve-hawkins/ee2c3b25a96d328631ac4fd338113fac)\r\n\r\n### Panic Output\r\n\r\nN/A\r\n\r\n### Expected Behavior\r\n\r\nThe Application Registration Service Principal Object ID should be returned\r\n\r\n### Actual Behavior\r\n\r\nA Service Principal for Application ID was not found\r\n\r\n### Steps to Reproduce\r\n\r\nThis part is hard to document as I have only noticed it on three out of five current Application Registrations.  I will add more here if I can find an issue with the actual Application Registrations, but as I mention in the section below using the Azure CLI I can find the Service Principal Object ID for all the five Application Registrations I have created.\r\n\r\n1. `terraform apply`\r\n\r\n### Important Factoids\r\n\r\n`az ad sp show --id '[REDACTED]'`\r\n\r\n```\r\n{\r\n  \"accountEnabled\": true,\r\n  \"addIns\": [],\r\n  \"alternativeNames\": [],\r\n  \"appDisplayName\": \"test_application\",\r\n  \"appId\": \"[REDACTED]\",\r\n  \"appOwnerTenantId\": \"[REDACTED]\",\r\n  \"appRoleAssignmentRequired\": false,\r\n  \"appRoles\": [],\r\n  \"deletionTimestamp\": null,\r\n  \"displayName\": \"test_application\",\r\n  \"errorUrl\": null,\r\n  \"homepage\": \"http://test_application\",\r\n  \"keyCredentials\": [],\r\n  \"logoutUrl\": null,\r\n  \"oauth2Permissions\": [\r\n    {\r\n      \"adminConsentDescription\": \"Allow the application to access test_application on behalf of the signed-in user.\",\r\n      \"adminConsentDisplayName\": \"Access test_application\",\r\n      \"id\": \"[REDACTED]\",\r\n      \"isEnabled\": true,\r\n      \"type\": \"User\",\r\n      \"userConsentDescription\": \"Allow the application to access test_application on your behalf.\",\r\n      \"userConsentDisplayName\": \"Access test_application\",\r\n      \"value\": \"user_impersonation\"\r\n    }\r\n  ],\r\n  **\"objectId\": \"[REDACTED]\",\r\n  \"objectType\": \"ServicePrincipal\",**\r\n  \"odata.metadata\": \"https://graph.windows.net/[REDACTED]/$metadata#directoryObjects/Microsoft.DirectoryServices.ServicePrincipal/@Element\",\r\n  \"odata.type\": \"Microsoft.DirectoryServices.ServicePrincipal\",\r\n  \"passwordCredentials\": [],\r\n  \"preferredTokenSigningKeyThumbprint\": null,\r\n  \"publisherName\": \"Steve Limited\",\r\n  \"replyUrls\": [],\r\n  \"samlMetadataUrl\": null,\r\n  \"servicePrincipalNames\": [\r\n    \"http://test_application\",\r\n    \"[REDACTED]\"\r\n  ],\r\n  \"servicePrincipalType\": \"Application\",\r\n  \"signInAudience\": \"AzureADMyOrg\",\r\n  \"tags\": [],\r\n  \"tokenEncryptionKeyId\": null\r\n}\r\n```\r\n\r\n### References\r\n\r\nN/A"},"comment":{"url":"https://api.github.com/repos/terraform-providers/terraform-provider-azurerm/issues/comments/417439255","html_url":"https://github.com/terraform-providers/terraform-provider-azurerm/issues/1844#issuecomment-417439255","issue_url":"https://api.github.com/repos/terraform-providers/terraform-provider-azurerm/issues/1844","id":417439255,"node_id":"MDEyOklzc3VlQ29tbWVudDQxNzQzOTI1NQ==","user":{"login":"tiwood","id":6249819,"node_id":"MDQ6VXNlcjYyNDk4MTk=","avatar_url":"https://avatars1.githubusercontent.com/u/6249819?v=4","gravatar_id":"","url":"https://api.github.com/users/tiwood","html_url":"https://github.com/tiwood","followers_url":"https://api.github.com/users/tiwood/followers","following_url":"https://api.github.com/users/tiwood/following{/other_user}","gists_url":"https://api.github.com/users/tiwood/gists{/gist_id}","starred_url":"https://api.github.com/users/tiwood/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tiwood/subscriptions","organizations_url":"https://api.github.com/users/tiwood/orgs","repos_url":"https://api.github.com/users/tiwood/repos","events_url":"https://api.github.com/users/tiwood/events{/privacy}","received_events_url":"https://api.github.com/users/tiwood/received_events","type":"User","site_admin":false},"created_at":"2018-08-30T19:28:43Z","updated_at":"2018-08-30T19:28:43Z","author_association":"NONE","body":"> This returns way over 100. (Is this the correct command?)\r\n\r\nYes, this is the correct command. If you are over 100 then you will have issues with the current iteration of the azuread resources.\r\n\r\n**Service Principal**\r\n- is unique to your Azure AD tenant\r\n- is used to authenticate against various APIs (Graph, Azure AD, etc.\r\n- is like a user account\r\n- is called Enterprise Registration (You register an Enterprise Application, which results in an Enterprise Registration  🤓️)\r\n\r\n**Application**\r\n- is the global representation of you application and contains (potential) global properties.\r\n- needs a registration in your Azure AD tenant to access stuff (again Registration --> Enterprise Registration (Service Principal)\r\n\r\n[https://stackoverflow.com/questions/46676634/authentication-difference-between-using-aad-app-key-and-service-principal-passwo/46678844#46678844](This) is a pretty good and short writeup. \r\n\r\n"}}
{"actor":{"display_login":"tiwood"}}