1. Packages
  2. Azure Active Directory (Azure AD)
  3. API Docs
  4. getServicePrincipals
Azure Active Directory (Azure AD) v6.4.0 published on Monday, Apr 7, 2025 by Pulumi

azuread.getServicePrincipals

Explore with Pulumi AI

Azure Active Directory (Azure AD) v6.4.0 published on Monday, Apr 7, 2025 by Pulumi

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",
    ],
});
Copy
import pulumi
import pulumi_azuread as azuread

example = azuread.get_service_principals(display_names=[
    "example-app",
    "another-app",
])
Copy
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
	})
}
Copy
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",
        },
    });

});
Copy
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());

    }
}
Copy
variables:
  example:
    fn::invoke:
      function: azuread:getServicePrincipals
      arguments:
        displayNames:
          - example-app
          - another-app
Copy

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",
    ],
});
Copy
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",
])
Copy
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
	})
}
Copy
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",
        },
    });

});
Copy
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());

    }
}
Copy
variables:
  example:
    fn::invoke:
      function: azuread:getServicePrincipals
      arguments:
        clientIds:
          - 11111111-0000-0000-0000-000000000000
          - 22222222-0000-0000-0000-000000000000
          - 33333333-0000-0000-0000-000000000000
Copy

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",
    ],
});
Copy
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",
])
Copy
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
	})
}
Copy
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",
        },
    });

});
Copy
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());

    }
}
Copy
variables:
  example:
    fn::invoke:
      function: azuread:getServicePrincipals
      arguments:
        objectIds:
          - 00000000-0000-0000-0000-000000000000
          - 00000000-0000-0000-0000-111111111111
          - 00000000-0000-0000-0000-222222222222
Copy

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>
Copy
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]
Copy
func GetServicePrincipals(ctx *Context, args *GetServicePrincipalsArgs, opts ...InvokeOption) (*GetServicePrincipalsResult, error)
func GetServicePrincipalsOutput(ctx *Context, args *GetServicePrincipalsOutputArgs, opts ...InvokeOption) GetServicePrincipalsResultOutput
Copy

> 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)
}
Copy
public static CompletableFuture<GetServicePrincipalsResult> getServicePrincipals(GetServicePrincipalsArgs args, InvokeOptions options)
public static Output<GetServicePrincipalsResult> getServicePrincipals(GetServicePrincipalsArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: azuread:index/getServicePrincipals:getServicePrincipals
  arguments:
    # arguments dictionary
Copy

The 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_names or object_ids must 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_names or object_ids must 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_names or object_ids must 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_names or object_ids must 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_names or object_ids must 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_names or object_ids must 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.AzureAD.Outputs.GetServicePrincipalsServicePrincipal>
A list of service principals. Each service_principal object 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 []GetServicePrincipalsServicePrincipal
A list of service principals. Each service_principal object 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<GetServicePrincipalsServicePrincipal>
A list of service principals. Each service_principal object 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 GetServicePrincipalsServicePrincipal[]
A list of service principals. Each service_principal object 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[GetServicePrincipalsServicePrincipal]
A list of service principals. Each service_principal object 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_principal object provides the attributes documented below.
ignoreMissing Boolean
returnAll Boolean

Supporting Types

GetServicePrincipalsServicePrincipal

AccountEnabled This property is required. bool
Whether the service principal account is enabled.
AppRoleAssignmentRequired This property is required. bool
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.
ApplicationTenantId This property is required. string
The tenant ID where the associated application is registered.
ClientId This property is required. string
The application ID (client ID) for the associated application
DisplayName This property is required. string
The display name of the application associated with this service principal.
ObjectId This property is required. string
The object ID of the service principal.
PreferredSingleSignOnMode This property is required. string
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.
SamlMetadataUrl This property is required. string
The URL where the service exposes SAML metadata for federation.
ServicePrincipalNames This property is required. List<string>
A list of identifier URI(s), copied over from the associated application.
SignInAudience This property is required. string
The Microsoft account types that are supported for the associated application. Possible values include AzureADMyOrg, AzureADMultipleOrgs, AzureADandPersonalMicrosoftAccount or PersonalMicrosoftAccount.
Tags This property is required. List<string>
A list of tags applied to the service principal.
Type This property is required. string
Identifies whether the service principal represents an application or a managed identity. Possible values include Application or ManagedIdentity.
AccountEnabled This property is required. bool
Whether the service principal account is enabled.
AppRoleAssignmentRequired This property is required. bool
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.
ApplicationTenantId This property is required. string
The tenant ID where the associated application is registered.
ClientId This property is required. string
The application ID (client ID) for the associated application
DisplayName This property is required. string
The display name of the application associated with this service principal.
ObjectId This property is required. string
The object ID of the service principal.
PreferredSingleSignOnMode This property is required. string
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.
SamlMetadataUrl This property is required. string
The URL where the service exposes SAML metadata for federation.
ServicePrincipalNames This property is required. []string
A list of identifier URI(s), copied over from the associated application.
SignInAudience This property is required. string
The Microsoft account types that are supported for the associated application. Possible values include AzureADMyOrg, AzureADMultipleOrgs, AzureADandPersonalMicrosoftAccount or PersonalMicrosoftAccount.
Tags This property is required. []string
A list of tags applied to the service principal.
Type This property is required. string
Identifies whether the service principal represents an application or a managed identity. Possible values include Application or ManagedIdentity.
accountEnabled This property is required. Boolean
Whether the service principal account is enabled.
appRoleAssignmentRequired This property is required. Boolean
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.
applicationTenantId This property is required. String
The tenant ID where the associated application is registered.
clientId This property is required. String
The application ID (client ID) for the associated application
displayName This property is required. String
The display name of the application associated with this service principal.
objectId This property is required. String
The object ID of the service principal.
preferredSingleSignOnMode This property is required. String
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.
samlMetadataUrl This property is required. String
The URL where the service exposes SAML metadata for federation.
servicePrincipalNames This property is required. List<String>
A list of identifier URI(s), copied over from the associated application.
signInAudience This property is required. String
The Microsoft account types that are supported for the associated application. Possible values include AzureADMyOrg, AzureADMultipleOrgs, AzureADandPersonalMicrosoftAccount or PersonalMicrosoftAccount.
tags This property is required. List<String>
A list of tags applied to the service principal.
type This property is required. String
Identifies whether the service principal represents an application or a managed identity. Possible values include Application or ManagedIdentity.
accountEnabled This property is required. boolean
Whether the service principal account is enabled.
appRoleAssignmentRequired This property is required. boolean
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.
applicationTenantId This property is required. string
The tenant ID where the associated application is registered.
clientId This property is required. string
The application ID (client ID) for the associated application
displayName This property is required. string
The display name of the application associated with this service principal.
objectId This property is required. string
The object ID of the service principal.
preferredSingleSignOnMode This property is required. string
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.
samlMetadataUrl This property is required. string
The URL where the service exposes SAML metadata for federation.
servicePrincipalNames This property is required. string[]
A list of identifier URI(s), copied over from the associated application.
signInAudience This property is required. string
The Microsoft account types that are supported for the associated application. Possible values include AzureADMyOrg, AzureADMultipleOrgs, AzureADandPersonalMicrosoftAccount or PersonalMicrosoftAccount.
tags This property is required. string[]
A list of tags applied to the service principal.
type This property is required. string
Identifies whether the service principal represents an application or a managed identity. Possible values include Application or ManagedIdentity.
account_enabled This property is required. bool
Whether the service principal account is enabled.
app_role_assignment_required This property is required. bool
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_id This property is required. str
The tenant ID where the associated application is registered.
client_id This property is required. str
The application ID (client ID) for the associated application
display_name This property is required. str
The display name of the application associated with this service principal.
object_id This property is required. str
The object ID of the service principal.
preferred_single_sign_on_mode This property is required. str
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_url This property is required. str
The URL where the service exposes SAML metadata for federation.
service_principal_names This property is required. Sequence[str]
A list of identifier URI(s), copied over from the associated application.
sign_in_audience This property is required. str
The Microsoft account types that are supported for the associated application. Possible values include AzureADMyOrg, AzureADMultipleOrgs, AzureADandPersonalMicrosoftAccount or PersonalMicrosoftAccount.
tags This property is required. Sequence[str]
A list of tags applied to the service principal.
type This property is required. str
Identifies whether the service principal represents an application or a managed identity. Possible values include Application or ManagedIdentity.
accountEnabled This property is required. Boolean
Whether the service principal account is enabled.
appRoleAssignmentRequired This property is required. Boolean
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.
applicationTenantId This property is required. String
The tenant ID where the associated application is registered.
clientId This property is required. String
The application ID (client ID) for the associated application
displayName This property is required. String
The display name of the application associated with this service principal.
objectId This property is required. String
The object ID of the service principal.
preferredSingleSignOnMode This property is required. String
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.
samlMetadataUrl This property is required. String
The URL where the service exposes SAML metadata for federation.
servicePrincipalNames This property is required. List<String>
A list of identifier URI(s), copied over from the associated application.
signInAudience This property is required. String
The Microsoft account types that are supported for the associated application. Possible values include AzureADMyOrg, AzureADMultipleOrgs, AzureADandPersonalMicrosoftAccount or PersonalMicrosoftAccount.
tags This property is required. List<String>
A list of tags applied to the service principal.
type This property is required. String
Identifies whether the service principal represents an application or a managed identity. Possible values include Application or ManagedIdentity.

Package Details

Repository
Azure Active Directory (Azure AD) pulumi/pulumi-azuread
License
Apache-2.0
Notes
This Pulumi package is based on the azuread Terraform Provider.
Azure Active Directory (Azure AD) v6.4.0 published on Monday, Apr 7, 2025 by Pulumi