azuread.getServicePrincipals
Explore with Pulumi AI
Gets basic information for multiple Azure Active Directory service principals.
API Permissions
The following API permissions are required in order to use this data source.
When authenticated with a service principal, this data source requires one of the following application roles: Application.Read.All or Directory.Read.All
When authenticated with a user principal, this data source does not require any additional roles.
Example Usage
Look up by application display names
import * as pulumi from "@pulumi/pulumi";
import * as azuread from "@pulumi/azuread";
const example = azuread.getServicePrincipals({
    displayNames: [
        "example-app",
        "another-app",
    ],
});
import pulumi
import pulumi_azuread as azuread
example = azuread.get_service_principals(display_names=[
    "example-app",
    "another-app",
])
package main
import (
	"github.com/pulumi/pulumi-azuread/sdk/v6/go/azuread"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := azuread.GetServicePrincipals(ctx, &azuread.GetServicePrincipalsArgs{
			DisplayNames: []string{
				"example-app",
				"another-app",
			},
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureAD = Pulumi.AzureAD;
return await Deployment.RunAsync(() => 
{
    var example = AzureAD.GetServicePrincipals.Invoke(new()
    {
        DisplayNames = new[]
        {
            "example-app",
            "another-app",
        },
    });
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azuread.AzureadFunctions;
import com.pulumi.azuread.inputs.GetServicePrincipalsArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }
    public static void stack(Context ctx) {
        final var example = AzureadFunctions.getServicePrincipals(GetServicePrincipalsArgs.builder()
            .displayNames(            
                "example-app",
                "another-app")
            .build());
    }
}
variables:
  example:
    fn::invoke:
      function: azuread:getServicePrincipals
      arguments:
        displayNames:
          - example-app
          - another-app
Look up by application IDs (client IDs)
import * as pulumi from "@pulumi/pulumi";
import * as azuread from "@pulumi/azuread";
const example = azuread.getServicePrincipals({
    clientIds: [
        "11111111-0000-0000-0000-000000000000",
        "22222222-0000-0000-0000-000000000000",
        "33333333-0000-0000-0000-000000000000",
    ],
});
import pulumi
import pulumi_azuread as azuread
example = azuread.get_service_principals(client_ids=[
    "11111111-0000-0000-0000-000000000000",
    "22222222-0000-0000-0000-000000000000",
    "33333333-0000-0000-0000-000000000000",
])
package main
import (
	"github.com/pulumi/pulumi-azuread/sdk/v6/go/azuread"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := azuread.GetServicePrincipals(ctx, &azuread.GetServicePrincipalsArgs{
			ClientIds: []string{
				"11111111-0000-0000-0000-000000000000",
				"22222222-0000-0000-0000-000000000000",
				"33333333-0000-0000-0000-000000000000",
			},
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureAD = Pulumi.AzureAD;
return await Deployment.RunAsync(() => 
{
    var example = AzureAD.GetServicePrincipals.Invoke(new()
    {
        ClientIds = new[]
        {
            "11111111-0000-0000-0000-000000000000",
            "22222222-0000-0000-0000-000000000000",
            "33333333-0000-0000-0000-000000000000",
        },
    });
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azuread.AzureadFunctions;
import com.pulumi.azuread.inputs.GetServicePrincipalsArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }
    public static void stack(Context ctx) {
        final var example = AzureadFunctions.getServicePrincipals(GetServicePrincipalsArgs.builder()
            .clientIds(            
                "11111111-0000-0000-0000-000000000000",
                "22222222-0000-0000-0000-000000000000",
                "33333333-0000-0000-0000-000000000000")
            .build());
    }
}
variables:
  example:
    fn::invoke:
      function: azuread:getServicePrincipals
      arguments:
        clientIds:
          - 11111111-0000-0000-0000-000000000000
          - 22222222-0000-0000-0000-000000000000
          - 33333333-0000-0000-0000-000000000000
Look up by service principal object IDs
import * as pulumi from "@pulumi/pulumi";
import * as azuread from "@pulumi/azuread";
const example = azuread.getServicePrincipals({
    objectIds: [
        "00000000-0000-0000-0000-000000000000",
        "00000000-0000-0000-0000-111111111111",
        "00000000-0000-0000-0000-222222222222",
    ],
});
import pulumi
import pulumi_azuread as azuread
example = azuread.get_service_principals(object_ids=[
    "00000000-0000-0000-0000-000000000000",
    "00000000-0000-0000-0000-111111111111",
    "00000000-0000-0000-0000-222222222222",
])
package main
import (
	"github.com/pulumi/pulumi-azuread/sdk/v6/go/azuread"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := azuread.GetServicePrincipals(ctx, &azuread.GetServicePrincipalsArgs{
			ObjectIds: []string{
				"00000000-0000-0000-0000-000000000000",
				"00000000-0000-0000-0000-111111111111",
				"00000000-0000-0000-0000-222222222222",
			},
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureAD = Pulumi.AzureAD;
return await Deployment.RunAsync(() => 
{
    var example = AzureAD.GetServicePrincipals.Invoke(new()
    {
        ObjectIds = new[]
        {
            "00000000-0000-0000-0000-000000000000",
            "00000000-0000-0000-0000-111111111111",
            "00000000-0000-0000-0000-222222222222",
        },
    });
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azuread.AzureadFunctions;
import com.pulumi.azuread.inputs.GetServicePrincipalsArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }
    public static void stack(Context ctx) {
        final var example = AzureadFunctions.getServicePrincipals(GetServicePrincipalsArgs.builder()
            .objectIds(            
                "00000000-0000-0000-0000-000000000000",
                "00000000-0000-0000-0000-111111111111",
                "00000000-0000-0000-0000-222222222222")
            .build());
    }
}
variables:
  example:
    fn::invoke:
      function: azuread:getServicePrincipals
      arguments:
        objectIds:
          - 00000000-0000-0000-0000-000000000000
          - 00000000-0000-0000-0000-111111111111
          - 00000000-0000-0000-0000-222222222222
Using getServicePrincipals
Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.
function getServicePrincipals(args: GetServicePrincipalsArgs, opts?: InvokeOptions): Promise<GetServicePrincipalsResult>
function getServicePrincipalsOutput(args: GetServicePrincipalsOutputArgs, opts?: InvokeOptions): Output<GetServicePrincipalsResult>def get_service_principals(client_ids: Optional[Sequence[str]] = None,
                           display_names: Optional[Sequence[str]] = None,
                           ignore_missing: Optional[bool] = None,
                           object_ids: Optional[Sequence[str]] = None,
                           return_all: Optional[bool] = None,
                           opts: Optional[InvokeOptions] = None) -> GetServicePrincipalsResult
def get_service_principals_output(client_ids: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
                           display_names: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
                           ignore_missing: Optional[pulumi.Input[bool]] = None,
                           object_ids: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
                           return_all: Optional[pulumi.Input[bool]] = None,
                           opts: Optional[InvokeOptions] = None) -> Output[GetServicePrincipalsResult]func GetServicePrincipals(ctx *Context, args *GetServicePrincipalsArgs, opts ...InvokeOption) (*GetServicePrincipalsResult, error)
func GetServicePrincipalsOutput(ctx *Context, args *GetServicePrincipalsOutputArgs, opts ...InvokeOption) GetServicePrincipalsResultOutput> Note: This function is named GetServicePrincipals in the Go SDK.
public static class GetServicePrincipals 
{
    public static Task<GetServicePrincipalsResult> InvokeAsync(GetServicePrincipalsArgs args, InvokeOptions? opts = null)
    public static Output<GetServicePrincipalsResult> Invoke(GetServicePrincipalsInvokeArgs args, InvokeOptions? opts = null)
}public static CompletableFuture<GetServicePrincipalsResult> getServicePrincipals(GetServicePrincipalsArgs args, InvokeOptions options)
public static Output<GetServicePrincipalsResult> getServicePrincipals(GetServicePrincipalsArgs args, InvokeOptions options)
fn::invoke:
  function: azuread:index/getServicePrincipals:getServicePrincipals
  arguments:
    # arguments dictionaryThe following arguments are supported:
- ClientIds List<string>
- A list of client IDs of the applications associated with the service principals.
- DisplayNames List<string>
- A list of display names of the applications associated with the service principals.
- IgnoreMissing bool
- Ignore missing service principals and return all service principals that are found. The data source will still fail if no service principals are found. Defaults to false.
- ObjectIds List<string>
- The object IDs of the service principals.
- ReturnAll bool
- When - true, the data source will return all service principals. Cannot be used with- ignore_missing. Defaults to false.- Either - return_all, or one of- client_ids,- display_namesor- object_idsmust be specified. These may be specified as an empty list, in which case no results will be returned.
- ClientIds []string
- A list of client IDs of the applications associated with the service principals.
- DisplayNames []string
- A list of display names of the applications associated with the service principals.
- IgnoreMissing bool
- Ignore missing service principals and return all service principals that are found. The data source will still fail if no service principals are found. Defaults to false.
- ObjectIds []string
- The object IDs of the service principals.
- ReturnAll bool
- When - true, the data source will return all service principals. Cannot be used with- ignore_missing. Defaults to false.- Either - return_all, or one of- client_ids,- display_namesor- object_idsmust be specified. These may be specified as an empty list, in which case no results will be returned.
- clientIds List<String>
- A list of client IDs of the applications associated with the service principals.
- displayNames List<String>
- A list of display names of the applications associated with the service principals.
- ignoreMissing Boolean
- Ignore missing service principals and return all service principals that are found. The data source will still fail if no service principals are found. Defaults to false.
- objectIds List<String>
- The object IDs of the service principals.
- returnAll Boolean
- When - true, the data source will return all service principals. Cannot be used with- ignore_missing. Defaults to false.- Either - return_all, or one of- client_ids,- display_namesor- object_idsmust be specified. These may be specified as an empty list, in which case no results will be returned.
- clientIds string[]
- A list of client IDs of the applications associated with the service principals.
- displayNames string[]
- A list of display names of the applications associated with the service principals.
- ignoreMissing boolean
- Ignore missing service principals and return all service principals that are found. The data source will still fail if no service principals are found. Defaults to false.
- objectIds string[]
- The object IDs of the service principals.
- returnAll boolean
- When - true, the data source will return all service principals. Cannot be used with- ignore_missing. Defaults to false.- Either - return_all, or one of- client_ids,- display_namesor- object_idsmust be specified. These may be specified as an empty list, in which case no results will be returned.
- client_ids Sequence[str]
- A list of client IDs of the applications associated with the service principals.
- display_names Sequence[str]
- A list of display names of the applications associated with the service principals.
- ignore_missing bool
- Ignore missing service principals and return all service principals that are found. The data source will still fail if no service principals are found. Defaults to false.
- object_ids Sequence[str]
- The object IDs of the service principals.
- return_all bool
- When - true, the data source will return all service principals. Cannot be used with- ignore_missing. Defaults to false.- Either - return_all, or one of- client_ids,- display_namesor- object_idsmust be specified. These may be specified as an empty list, in which case no results will be returned.
- clientIds List<String>
- A list of client IDs of the applications associated with the service principals.
- displayNames List<String>
- A list of display names of the applications associated with the service principals.
- ignoreMissing Boolean
- Ignore missing service principals and return all service principals that are found. The data source will still fail if no service principals are found. Defaults to false.
- objectIds List<String>
- The object IDs of the service principals.
- returnAll Boolean
- When - true, the data source will return all service principals. Cannot be used with- ignore_missing. Defaults to false.- Either - return_all, or one of- client_ids,- display_namesor- object_idsmust be specified. These may be specified as an empty list, in which case no results will be returned.
getServicePrincipals Result
The following output properties are available:
- ClientIds List<string>
- The client ID of the application associated with this service principal.
- DisplayNames List<string>
- A list of display names of the applications associated with the service principals.
- Id string
- The provider-assigned unique ID for this managed resource.
- ObjectIds List<string>
- The object IDs of the service principals.
- ServicePrincipals List<Pulumi.Azure AD. Outputs. Get Service Principals Service Principal> 
- A list of service principals. Each service_principalobject provides the attributes documented below.
- IgnoreMissing bool
- ReturnAll bool
- ClientIds []string
- The client ID of the application associated with this service principal.
- DisplayNames []string
- A list of display names of the applications associated with the service principals.
- Id string
- The provider-assigned unique ID for this managed resource.
- ObjectIds []string
- The object IDs of the service principals.
- ServicePrincipals []GetService Principals Service Principal 
- A list of service principals. Each service_principalobject provides the attributes documented below.
- IgnoreMissing bool
- ReturnAll bool
- clientIds List<String>
- The client ID of the application associated with this service principal.
- displayNames List<String>
- A list of display names of the applications associated with the service principals.
- id String
- The provider-assigned unique ID for this managed resource.
- objectIds List<String>
- The object IDs of the service principals.
- servicePrincipals List<GetService Principals Service Principal> 
- A list of service principals. Each service_principalobject provides the attributes documented below.
- ignoreMissing Boolean
- returnAll Boolean
- clientIds string[]
- The client ID of the application associated with this service principal.
- displayNames string[]
- A list of display names of the applications associated with the service principals.
- id string
- The provider-assigned unique ID for this managed resource.
- objectIds string[]
- The object IDs of the service principals.
- servicePrincipals GetService Principals Service Principal[] 
- A list of service principals. Each service_principalobject provides the attributes documented below.
- ignoreMissing boolean
- returnAll boolean
- client_ids Sequence[str]
- The client ID of the application associated with this service principal.
- display_names Sequence[str]
- A list of display names of the applications associated with the service principals.
- id str
- The provider-assigned unique ID for this managed resource.
- object_ids Sequence[str]
- The object IDs of the service principals.
- service_principals Sequence[GetService Principals Service Principal] 
- A list of service principals. Each service_principalobject provides the attributes documented below.
- ignore_missing bool
- return_all bool
- clientIds List<String>
- The client ID of the application associated with this service principal.
- displayNames List<String>
- A list of display names of the applications associated with the service principals.
- id String
- The provider-assigned unique ID for this managed resource.
- objectIds List<String>
- The object IDs of the service principals.
- servicePrincipals List<Property Map>
- A list of service principals. Each service_principalobject provides the attributes documented below.
- ignoreMissing Boolean
- returnAll Boolean
Supporting Types
GetServicePrincipalsServicePrincipal    
- AccountEnabled bool
- Whether the service principal account is enabled.
- AppRole boolAssignment Required 
- Whether this service principal requires an app role assignment to a user or group before Azure AD will issue a user or access token to the application.
- ApplicationTenant stringId 
- The tenant ID where the associated application is registered.
- ClientId string
- The application ID (client ID) for the associated application
- DisplayName string
- The display name of the application associated with this service principal.
- ObjectId string
- The object ID of the service principal.
- PreferredSingle stringSign On Mode 
- The single sign-on mode configured for this application. Azure AD uses the preferred single sign-on mode to launch the application from Microsoft 365 or the Azure AD My Apps.
- SamlMetadata stringUrl 
- The URL where the service exposes SAML metadata for federation.
- ServicePrincipal List<string>Names 
- A list of identifier URI(s), copied over from the associated application.
- SignIn stringAudience 
- The Microsoft account types that are supported for the associated application. Possible values include AzureADMyOrg,AzureADMultipleOrgs,AzureADandPersonalMicrosoftAccountorPersonalMicrosoftAccount.
- List<string>
- A list of tags applied to the service principal.
- Type string
- Identifies whether the service principal represents an application or a managed identity. Possible values include ApplicationorManagedIdentity.
- AccountEnabled bool
- Whether the service principal account is enabled.
- AppRole boolAssignment Required 
- Whether this service principal requires an app role assignment to a user or group before Azure AD will issue a user or access token to the application.
- ApplicationTenant stringId 
- The tenant ID where the associated application is registered.
- ClientId string
- The application ID (client ID) for the associated application
- DisplayName string
- The display name of the application associated with this service principal.
- ObjectId string
- The object ID of the service principal.
- PreferredSingle stringSign On Mode 
- The single sign-on mode configured for this application. Azure AD uses the preferred single sign-on mode to launch the application from Microsoft 365 or the Azure AD My Apps.
- SamlMetadata stringUrl 
- The URL where the service exposes SAML metadata for federation.
- ServicePrincipal []stringNames 
- A list of identifier URI(s), copied over from the associated application.
- SignIn stringAudience 
- The Microsoft account types that are supported for the associated application. Possible values include AzureADMyOrg,AzureADMultipleOrgs,AzureADandPersonalMicrosoftAccountorPersonalMicrosoftAccount.
- []string
- A list of tags applied to the service principal.
- Type string
- Identifies whether the service principal represents an application or a managed identity. Possible values include ApplicationorManagedIdentity.
- accountEnabled Boolean
- Whether the service principal account is enabled.
- appRole BooleanAssignment Required 
- Whether this service principal requires an app role assignment to a user or group before Azure AD will issue a user or access token to the application.
- applicationTenant StringId 
- The tenant ID where the associated application is registered.
- clientId String
- The application ID (client ID) for the associated application
- displayName String
- The display name of the application associated with this service principal.
- objectId String
- The object ID of the service principal.
- preferredSingle StringSign On Mode 
- The single sign-on mode configured for this application. Azure AD uses the preferred single sign-on mode to launch the application from Microsoft 365 or the Azure AD My Apps.
- samlMetadata StringUrl 
- The URL where the service exposes SAML metadata for federation.
- servicePrincipal List<String>Names 
- A list of identifier URI(s), copied over from the associated application.
- signIn StringAudience 
- The Microsoft account types that are supported for the associated application. Possible values include AzureADMyOrg,AzureADMultipleOrgs,AzureADandPersonalMicrosoftAccountorPersonalMicrosoftAccount.
- List<String>
- A list of tags applied to the service principal.
- type String
- Identifies whether the service principal represents an application or a managed identity. Possible values include ApplicationorManagedIdentity.
- accountEnabled boolean
- Whether the service principal account is enabled.
- appRole booleanAssignment Required 
- Whether this service principal requires an app role assignment to a user or group before Azure AD will issue a user or access token to the application.
- applicationTenant stringId 
- The tenant ID where the associated application is registered.
- clientId string
- The application ID (client ID) for the associated application
- displayName string
- The display name of the application associated with this service principal.
- objectId string
- The object ID of the service principal.
- preferredSingle stringSign On Mode 
- The single sign-on mode configured for this application. Azure AD uses the preferred single sign-on mode to launch the application from Microsoft 365 or the Azure AD My Apps.
- samlMetadata stringUrl 
- The URL where the service exposes SAML metadata for federation.
- servicePrincipal string[]Names 
- A list of identifier URI(s), copied over from the associated application.
- signIn stringAudience 
- The Microsoft account types that are supported for the associated application. Possible values include AzureADMyOrg,AzureADMultipleOrgs,AzureADandPersonalMicrosoftAccountorPersonalMicrosoftAccount.
- string[]
- A list of tags applied to the service principal.
- type string
- Identifies whether the service principal represents an application or a managed identity. Possible values include ApplicationorManagedIdentity.
- account_enabled bool
- Whether the service principal account is enabled.
- app_role_ boolassignment_ required 
- Whether this service principal requires an app role assignment to a user or group before Azure AD will issue a user or access token to the application.
- application_tenant_ strid 
- The tenant ID where the associated application is registered.
- client_id str
- The application ID (client ID) for the associated application
- display_name str
- The display name of the application associated with this service principal.
- object_id str
- The object ID of the service principal.
- preferred_single_ strsign_ on_ mode 
- The single sign-on mode configured for this application. Azure AD uses the preferred single sign-on mode to launch the application from Microsoft 365 or the Azure AD My Apps.
- saml_metadata_ strurl 
- The URL where the service exposes SAML metadata for federation.
- service_principal_ Sequence[str]names 
- A list of identifier URI(s), copied over from the associated application.
- sign_in_ straudience 
- The Microsoft account types that are supported for the associated application. Possible values include AzureADMyOrg,AzureADMultipleOrgs,AzureADandPersonalMicrosoftAccountorPersonalMicrosoftAccount.
- Sequence[str]
- A list of tags applied to the service principal.
- type str
- Identifies whether the service principal represents an application or a managed identity. Possible values include ApplicationorManagedIdentity.
- accountEnabled Boolean
- Whether the service principal account is enabled.
- appRole BooleanAssignment Required 
- Whether this service principal requires an app role assignment to a user or group before Azure AD will issue a user or access token to the application.
- applicationTenant StringId 
- The tenant ID where the associated application is registered.
- clientId String
- The application ID (client ID) for the associated application
- displayName String
- The display name of the application associated with this service principal.
- objectId String
- The object ID of the service principal.
- preferredSingle StringSign On Mode 
- The single sign-on mode configured for this application. Azure AD uses the preferred single sign-on mode to launch the application from Microsoft 365 or the Azure AD My Apps.
- samlMetadata StringUrl 
- The URL where the service exposes SAML metadata for federation.
- servicePrincipal List<String>Names 
- A list of identifier URI(s), copied over from the associated application.
- signIn StringAudience 
- The Microsoft account types that are supported for the associated application. Possible values include AzureADMyOrg,AzureADMultipleOrgs,AzureADandPersonalMicrosoftAccountorPersonalMicrosoftAccount.
- List<String>
- A list of tags applied to the service principal.
- type String
- Identifies whether the service principal represents an application or a managed identity. Possible values include ApplicationorManagedIdentity.
Package Details
- Repository
- Azure Active Directory (Azure AD) pulumi/pulumi-azuread
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the azureadTerraform Provider.