class AppIdentity
A data class representing the identity of an Azure Active Directory application that performed an action or was changed, used in directory audit operations.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/applications/app_identity.py
4 - 26
simple
Purpose
AppIdentity is a value object that encapsulates application identity information from Azure Active Directory. It stores the application ID, display name, service principal ID, and service principal name. This class is primarily used in directory audit operations to track which application performed specific actions or underwent changes. It inherits from ClientValue, making it suitable for serialization and transmission in API operations related to Office 365 and Azure AD auditing.
Source Code
class AppIdentity(ClientValue):
"""Indicates the identity of the application that performed the action or was changed.
Includes application ID, name, and service principal ID and name. This resource is used by the
Get directoryAudit operation."""
def __init__(
self,
app_id=None,
display_name=None,
service_principal_id=None,
service_principal_name=None,
):
"""
:param str app_id: Refers to the Unique GUID representing Application Id in the Azure Active Directory.
:param str display_name: Refers to the Application Name displayed in the Azure Portal.
:param str service_principal_id: Refers to the Unique GUID indicating Service Principal Id in Azure Active
Directory for the corresponding App.
:param str service_principal_name: Refers to the Service Principal Name is the Application name in the tenant.
"""
self.appId = app_id
self.displayName = display_name
self.servicePrincipalId = service_principal_id
self.servicePrincipalName = service_principal_name
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
ClientValue | - |
Parameter Details
app_id: The unique GUID (Globally Unique Identifier) representing the Application ID in Azure Active Directory. This is the primary identifier for the application. Optional parameter, defaults to None if not provided.
display_name: The human-readable name of the application as displayed in the Azure Portal. This is the friendly name users see when interacting with the application. Optional parameter, defaults to None if not provided.
service_principal_id: The unique GUID indicating the Service Principal ID in Azure Active Directory for the corresponding application. The service principal is the local representation of the application in a specific tenant. Optional parameter, defaults to None if not provided.
service_principal_name: The Service Principal Name, which is the application name within the tenant context. This is used for authentication and authorization purposes. Optional parameter, defaults to None if not provided.
Return Value
Instantiation returns an AppIdentity object with four instance attributes (appId, displayName, servicePrincipalId, servicePrincipalName) set to the provided parameter values or None. The object represents a complete application identity snapshot for audit purposes.
Class Interface
Methods
__init__(self, app_id=None, display_name=None, service_principal_id=None, service_principal_name=None)
Purpose: Initializes an AppIdentity instance with application and service principal identity information
Parameters:
app_id: Unique GUID representing Application ID in Azure Active Directorydisplay_name: Application name displayed in the Azure Portalservice_principal_id: Unique GUID indicating Service Principal ID in Azure Active Directoryservice_principal_name: Service Principal Name (application name in the tenant)
Returns: None (constructor)
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
appId |
str or None | Stores the unique GUID representing the Application ID in Azure Active Directory | instance |
displayName |
str or None | Stores the human-readable application name as displayed in the Azure Portal | instance |
servicePrincipalId |
str or None | Stores the unique GUID indicating the Service Principal ID in Azure Active Directory | instance |
servicePrincipalName |
str or None | Stores the Service Principal Name, which is the application name within the tenant | instance |
Dependencies
office365
Required Imports
from office365.runtime.client_value import ClientValue
Usage Example
from office365.runtime.client_value import ClientValue
# Create an AppIdentity instance with full information
app_identity = AppIdentity(
app_id='12345678-1234-1234-1234-123456789abc',
display_name='My Application',
service_principal_id='87654321-4321-4321-4321-cba987654321',
service_principal_name='MyApp@tenant.onmicrosoft.com'
)
# Access the attributes
print(app_identity.appId) # '12345678-1234-1234-1234-123456789abc'
print(app_identity.displayName) # 'My Application'
print(app_identity.servicePrincipalId) # '87654321-4321-4321-4321-cba987654321'
print(app_identity.servicePrincipalName) # 'MyApp@tenant.onmicrosoft.com'
# Create with partial information
partial_identity = AppIdentity(
app_id='12345678-1234-1234-1234-123456789abc',
display_name='My Application'
)
# Unset attributes will be None
print(partial_identity.servicePrincipalId) # None
Best Practices
- This is an immutable-style value object - after creation, attributes should typically not be modified to maintain data integrity in audit contexts.
- All constructor parameters are optional, but for meaningful audit records, at least app_id and display_name should be provided.
- Use this class when working with Azure AD directory audit logs to represent application identity information consistently.
- The class follows Azure AD naming conventions with camelCase attribute names (appId, displayName, etc.) to match the Azure AD API schema.
- Since this inherits from ClientValue, it is designed for serialization and should be used as a data transfer object rather than containing business logic.
- When parsing audit logs or API responses, instantiate this class with the corresponding fields from the Azure AD response.
- GUIDs for app_id and service_principal_id should be in standard GUID format (8-4-4-4-12 hexadecimal digits).
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class UserIdentity 75.6% similar
-
class Identity 69.6% similar
-
class AuditActivityInitiator 66.7% similar
-
class ActivityIdentity 66.4% similar
-
class TenantAppInformation 65.3% similar