class ApplicationTemplate
Represents an application template in the Azure AD application gallery, providing methods to instantiate applications and access their metadata.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/applications/template.py
7 - 58
moderate
Purpose
This class serves as a wrapper for Azure AD application gallery templates, allowing developers to programmatically instantiate applications from the gallery into their directory, retrieve application metadata such as display name, categories, and supported authentication modes. It inherits from Entity and integrates with the Office365 SDK's query and context management system to perform operations against the Microsoft Graph API.
Source Code
class ApplicationTemplate(Entity):
"""Represents an application in the Azure AD application gallery."""
def instantiate(self, display_name):
"""
Add an instance of an application from the Azure AD application gallery into your directory. You can also use
this API to instantiate non-gallery apps.
Use the following ID for the applicationTemplate object: 8adf8e6e-67b2-4cf2-a259-e3dc5476c621.
:param str display_name: Custom name of the application
"""
return_type = ClientResult(self.context)
payload = {"displayName": display_name}
qry = ServiceOperationQuery(
self, "instantiate", None, payload, None, return_type
)
self.context.add_query(qry)
return return_type
@property
def display_name(self):
"""
The name of the application.
:rtype: str or None
"""
return self.properties.get("displayName", None)
@property
def categories(self):
"""
The list of categories for the application. Supported values can be: Collaboration, Business Management,
Consumer, Content management, CRM, Data services, Developer services, E-commerce, Education, ERP, Finance,
Health, Human resources, IT infrastructure, Mail, Management, Marketing, Media, Productivity,
Project management, Telecommunications, Tools, Travel, and Web design & hosting.
"""
return self.properties.get("categories", StringCollection())
@property
def supported_provisioning_types(self):
"""
The list of provisioning modes supported by this application
"""
return self.properties.get("supportedProvisioningTypes", StringCollection())
@property
def supported_single_signon_modes(self):
"""
The list of single sign-on modes supported by this application.
The supported values are oidc, password, saml, and notSupported.
"""
return self.properties.get("supportedSingleSignOnModes", StringCollection())
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
Entity | - |
Parameter Details
context: Inherited from Entity base class - the client context object that manages API communication and authentication with Azure AD/Microsoft Graph
properties: Inherited from Entity base class - dictionary containing the application template's properties retrieved from the API
Return Value
Instantiation returns an ApplicationTemplate object that represents a specific application template in the Azure AD gallery. The instantiate() method returns a ClientResult object that will contain the result of the instantiation operation after the query is executed. Properties return either strings (display_name) or StringCollection objects (categories, supported_provisioning_types, supported_single_signon_modes).
Class Interface
Methods
instantiate(display_name: str) -> ClientResult
Purpose: Creates an instance of the application template in the Azure AD directory with a custom display name
Parameters:
display_name: Custom name for the application instance being created in the directory
Returns: ClientResult object that will contain the instantiation result after execute_query() is called on the context
@property display_name() -> str | None
property
Purpose: Gets the name of the application template
Returns: String containing the application template name, or None if not set
@property categories() -> StringCollection
property
Purpose: Gets the list of categories this application belongs to (e.g., Collaboration, CRM, Finance)
Returns: StringCollection containing category names from a predefined set of supported values
@property supported_provisioning_types() -> StringCollection
property
Purpose: Gets the list of provisioning modes supported by this application template
Returns: StringCollection containing supported provisioning type identifiers
@property supported_single_signon_modes() -> StringCollection
property
Purpose: Gets the list of single sign-on authentication modes supported by this application
Returns: StringCollection containing SSO mode identifiers: 'oidc', 'password', 'saml', or 'notSupported'
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
context |
ClientContext | Inherited from Entity - the client context managing API communication and query execution | instance |
properties |
dict | Inherited from Entity - dictionary storing the application template's properties retrieved from the API | instance |
Dependencies
office365
Required Imports
from office365.entity import Entity
from office365.runtime.client_result import ClientResult
from office365.runtime.queries.service_operation import ServiceOperationQuery
from office365.runtime.types.collections import StringCollection
Usage Example
from office365.graph_client import GraphClient
from office365.directory.applications.templates.application_template import ApplicationTemplate
# Authenticate and create context
client = GraphClient.with_client_secret(tenant_id, client_id, client_secret)
# Get an application template by ID
template_id = '8adf8e6e-67b2-4cf2-a259-e3dc5476c621'
app_template = client.application_templates[template_id].get().execute_query()
# Access template properties
print(f"Template Name: {app_template.display_name}")
print(f"Categories: {app_template.categories}")
print(f"SSO Modes: {app_template.supported_single_signon_modes}")
# Instantiate the application in your directory
result = app_template.instantiate('My Custom App Name')
client.execute_query()
print(f"Application instantiated: {result.value}")
Best Practices
- Always call execute_query() on the context after calling instantiate() to actually perform the operation
- The instantiate() method returns a ClientResult object that will be populated after execute_query() is called
- Use the special ID '8adf8e6e-67b2-4cf2-a259-e3dc5476c621' for instantiating non-gallery apps
- Check supported_single_signon_modes before configuring SSO to ensure the desired mode is supported
- Properties are lazily loaded - ensure the entity is loaded via get().execute_query() before accessing properties
- The display_name parameter in instantiate() is the custom name for your instance, not the template name
- Handle None returns from properties gracefully as they may not be populated until the entity is fully loaded
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class Application 70.8% similar
-
class ApplicationServicePrincipal 67.5% similar
-
class ApplicationCollection 64.4% similar
-
class DirectoryRoleTemplate 63.0% similar
-
class AppRole 59.9% similar