class TenantAppInstance
Represents an instance of a tenant-scoped app for a given host web in SharePoint, inheriting from the Entity base class.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/tenant/apps/instance.py
4 - 5
simple
Purpose
This class models a tenant app instance in SharePoint Online, which represents an app that has been deployed at the tenant level and instantiated for a specific host web. It provides an object-oriented interface for interacting with tenant-scoped app instances through the SharePoint REST API, allowing developers to manage and query app instances that are available across a SharePoint tenant.
Source Code
class TenantAppInstance(Entity):
"""Represents an instance of a tenant-scoped app for a given host web."""
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
Entity | - |
Parameter Details
context: The client context object that provides the connection to the SharePoint site and handles authentication and request execution
resource_path: Optional parameter specifying the server-relative path to the tenant app instance resource in SharePoint
properties: Optional dictionary of initial property values to set on the entity instance
Return Value
Instantiation returns a TenantAppInstance object that represents a tenant-scoped app instance. The object inherits all methods and properties from the Entity base class, providing access to SharePoint entity operations like get(), update(), and delete(). Method return values depend on the inherited Entity class methods.
Class Interface
Methods
__init__(context, resource_path=None, properties=None)
Purpose: Initializes a new TenantAppInstance entity object
Parameters:
context: The ClientContext object for SharePoint communicationresource_path: Optional server-relative path to the resourceproperties: Optional dictionary of initial property values
Returns: A new TenantAppInstance object
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
context |
ClientContext | The client context used for communication with SharePoint | instance |
resource_path |
ResourcePath | The server-relative path to this entity in SharePoint | instance |
properties |
dict | Dictionary containing the entity's properties loaded from SharePoint | instance |
Dependencies
office365-runtimeoffice365-sharepoint
Required Imports
from office365.sharepoint.tenant.administration.tenant_app_instance import TenantAppInstance
Usage Example
from office365.sharepoint.client_context import ClientContext
from office365.runtime.auth.user_credential import UserCredential
from office365.sharepoint.tenant.administration.tenant_app_instance import TenantAppInstance
# Authenticate to SharePoint
site_url = 'https://contoso.sharepoint.com/sites/site1'
credentials = UserCredential('user@contoso.com', 'password')
ctx = ClientContext(site_url).with_credentials(credentials)
# Get a tenant app instance
app_instance = ctx.web.tenant_app_catalog.get_by_id('app-instance-id')
ctx.load(app_instance)
ctx.execute_query()
# Access properties
print(f'App Instance ID: {app_instance.id}')
print(f'App Instance Title: {app_instance.title}')
Best Practices
- Always authenticate with appropriate tenant or site collection administrator permissions before accessing tenant app instances
- Use the ClientContext.load() method followed by execute_query() to retrieve entity properties from SharePoint
- Handle exceptions when accessing app instances as they may not exist or permissions may be insufficient
- Dispose of the ClientContext properly after operations are complete to release resources
- Use the inherited Entity methods (get(), update(), delete()) for CRUD operations on the app instance
- Check if the app instance exists before attempting to access its properties to avoid null reference errors
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class TenantAppUtility 74.0% similar
-
class TenantAppInformation 67.5% similar
-
class Tenant 67.4% similar
-
class HostedApp 67.0% similar
-
class TeamsApp 66.4% similar