Microsoft Azure Search Management Client Library for Python
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Configuration of private endpoints, private link resources, and shared private link resources for secure network connectivity to search services. This enables private communication between search services and other Azure resources without traversing the public internet.
Discover and list the types of private link resources supported by the search service, which defines what Azure resources can establish private connections.
def list_supported(
resource_group_name: str,
search_service_name: str,
*,
client_request_id: Optional[str] = None,
**kwargs
) -> ItemPaged[PrivateLinkResource]:
"""
List supported private link resource types for the search service.
Parameters:
resource_group_name (str): Resource group name
search_service_name (str): Search service name
client_request_id (str, optional): Client-generated request ID
Returns:
ItemPaged[PrivateLinkResource]: Supported private link resource types
Raises:
ResourceNotFoundError: Service does not exist
"""Manage private endpoint connections that allow other Azure resources to connect privately to the search service through Azure Private Link.
def update(
resource_group_name: str,
search_service_name: str,
private_endpoint_connection_name: str,
private_endpoint_connection: PrivateEndpointConnection,
*,
client_request_id: Optional[str] = None,
**kwargs
) -> PrivateEndpointConnection:
"""
Update a private endpoint connection.
Parameters:
resource_group_name (str): Resource group name
search_service_name (str): Search service name
private_endpoint_connection_name (str): Private endpoint connection name
private_endpoint_connection (PrivateEndpointConnection): Connection configuration
client_request_id (str, optional): Client-generated request ID
Returns:
PrivateEndpointConnection: Updated connection configuration
Raises:
ResourceNotFoundError: Service or connection does not exist
"""
def get(
resource_group_name: str,
search_service_name: str,
private_endpoint_connection_name: str,
*,
client_request_id: Optional[str] = None,
**kwargs
) -> PrivateEndpointConnection:
"""
Get a private endpoint connection by name.
Parameters:
resource_group_name (str): Resource group name
search_service_name (str): Search service name
private_endpoint_connection_name (str): Connection name
client_request_id (str, optional): Client-generated request ID
Returns:
PrivateEndpointConnection: Connection details and status
Raises:
ResourceNotFoundError: Service or connection does not exist
"""
def delete(
resource_group_name: str,
search_service_name: str,
private_endpoint_connection_name: str,
*,
client_request_id: Optional[str] = None,
**kwargs
) -> PrivateEndpointConnection:
"""
Delete a private endpoint connection.
Parameters:
resource_group_name (str): Resource group name
search_service_name (str): Search service name
private_endpoint_connection_name (str): Connection name to delete
client_request_id (str, optional): Client-generated request ID
Returns:
PrivateEndpointConnection: Deleted connection details
Raises:
ResourceNotFoundError: Service or connection does not exist
"""
def list_by_service(
resource_group_name: str,
search_service_name: str,
*,
client_request_id: Optional[str] = None,
**kwargs
) -> ItemPaged[PrivateEndpointConnection]:
"""
List all private endpoint connections for a search service.
Parameters:
resource_group_name (str): Resource group name
search_service_name (str): Search service name
client_request_id (str, optional): Client-generated request ID
Returns:
ItemPaged[PrivateEndpointConnection]: All private endpoint connections
"""Manage shared private link resources that allow the search service to connect privately to other Azure resources like storage accounts, Cosmos DB, or SQL databases.
def create_or_update(
resource_group_name: str,
search_service_name: str,
shared_private_link_resource_name: str,
shared_private_link_resource: SharedPrivateLinkResource,
*,
client_request_id: Optional[str] = None,
**kwargs
) -> LROPoller[SharedPrivateLinkResource]:
"""
Create or update a shared private link resource.
Parameters:
resource_group_name (str): Resource group name
search_service_name (str): Search service name
shared_private_link_resource_name (str): Shared resource name
shared_private_link_resource (SharedPrivateLinkResource): Resource configuration
client_request_id (str, optional): Client-generated request ID
Returns:
LROPoller[SharedPrivateLinkResource]: Long-running operation for resource creation
Raises:
HttpResponseError: Invalid configuration or quota exceeded
"""
def get(
resource_group_name: str,
search_service_name: str,
shared_private_link_resource_name: str,
*,
client_request_id: Optional[str] = None,
**kwargs
) -> SharedPrivateLinkResource:
"""
Get a shared private link resource by name.
Parameters:
resource_group_name (str): Resource group name
search_service_name (str): Search service name
shared_private_link_resource_name (str): Resource name
client_request_id (str, optional): Client-generated request ID
Returns:
SharedPrivateLinkResource: Resource configuration and status
Raises:
ResourceNotFoundError: Service or resource does not exist
"""
def delete(
resource_group_name: str,
search_service_name: str,
shared_private_link_resource_name: str,
*,
client_request_id: Optional[str] = None,
**kwargs
) -> LROPoller[None]:
"""
Delete a shared private link resource.
Parameters:
resource_group_name (str): Resource group name
search_service_name (str): Search service name
shared_private_link_resource_name (str): Resource name to delete
client_request_id (str, optional): Client-generated request ID
Returns:
LROPoller[None]: Long-running operation for resource deletion
"""
def list_by_service(
resource_group_name: str,
search_service_name: str,
*,
client_request_id: Optional[str] = None,
**kwargs
) -> ItemPaged[SharedPrivateLinkResource]:
"""
List all shared private link resources for a search service.
Parameters:
resource_group_name (str): Resource group name
search_service_name (str): Search service name
client_request_id (str, optional): Client-generated request ID
Returns:
ItemPaged[SharedPrivateLinkResource]: All shared private link resources
"""Usage Example:
from azure.mgmt.search.models import (
SharedPrivateLinkResource,
SharedPrivateLinkResourceProperties,
PrivateEndpointConnection,
PrivateEndpointConnectionProperties,
PrivateEndpointConnectionPropertiesPrivateLinkServiceConnectionState,
PrivateLinkServiceConnectionStatus
)
# List supported private link resource types
supported_resources = client.private_link_resources.list_supported(
"my-resource-group",
"my-search-service"
)
for resource in supported_resources:
print(f"Supported: {resource.name} - {resource.properties.shareable_private_link_resource_types}")
# Create shared private link to storage account
storage_private_link = SharedPrivateLinkResource(
properties=SharedPrivateLinkResourceProperties(
private_link_resource_id="/subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.Storage/storageAccounts/mystorage",
group_id="blob",
request_message="Please approve this connection for search service"
)
)
# Start creation operation
create_operation = client.shared_private_link_resources.begin_create_or_update(
resource_group_name="my-resource-group",
search_service_name="my-search-service",
shared_private_link_resource_name="storage-connection",
shared_private_link_resource=storage_private_link
)
# Wait for completion
shared_resource = create_operation.result()
print(f"Shared resource created: {shared_resource.name}")
print(f"Status: {shared_resource.properties.status}")
# List all private endpoint connections
pe_connections = client.private_endpoint_connections.list_by_service(
"my-resource-group",
"my-search-service"
)
for connection in pe_connections:
print(f"PE Connection: {connection.name} - {connection.properties.private_link_service_connection_state.status}")Describes the types of private link resources supported by the search service.
class PrivateLinkResource:
"""
Private link resource type supported by the search service.
Attributes:
id (str): Resource ID
name (str): Resource name
type (str): Resource type
properties (PrivateLinkResourceProperties): Resource properties
"""
class PrivateLinkResourceProperties:
"""
Properties of a private link resource.
Attributes:
group_id (str): Group ID for the private link resource
required_members (List[str]): Required members for the resource
required_zone_names (List[str]): Required DNS zone names
shareable_private_link_resource_types (List[ShareablePrivateLinkResourceType]): Shareable resource types
"""Represents a private endpoint connection to the search service.
class PrivateEndpointConnection:
"""
Private endpoint connection configuration.
Attributes:
id (str): Connection resource ID
name (str): Connection name
type (str): Resource type
properties (PrivateEndpointConnectionProperties): Connection properties
"""
class PrivateEndpointConnectionProperties:
"""
Private endpoint connection properties.
Attributes:
private_endpoint (PrivateEndpointConnectionPropertiesPrivateEndpoint): Private endpoint info
private_link_service_connection_state (PrivateEndpointConnectionPropertiesPrivateLinkServiceConnectionState): Connection state
provisioning_state (PrivateLinkServiceConnectionProvisioningState): Provisioning state
"""
class PrivateEndpointConnectionPropertiesPrivateLinkServiceConnectionState:
"""
Private link service connection state.
Attributes:
status (PrivateLinkServiceConnectionStatus): Connection status
description (str): Connection description
actions_required (str): Required actions
"""Configuration for shared private link resources that connect the search service to other Azure resources.
class SharedPrivateLinkResource:
"""
Shared private link resource configuration.
Attributes:
id (str): Resource ID
name (str): Resource name
type (str): Resource type
properties (SharedPrivateLinkResourceProperties): Resource properties
"""
class SharedPrivateLinkResourceProperties:
"""
Shared private link resource properties.
Attributes:
private_link_resource_id (str): Target resource ID to connect to
group_id (str): Group ID of the target resource
request_message (str): Message for connection approval
resource_region (str): Target resource region
status (SharedPrivateLinkResourceStatus): Connection status
provisioning_state (SharedPrivateLinkResourceProvisioningState): Provisioning state
"""class PrivateLinkServiceConnectionStatus(str, Enum):
"""Private endpoint connection status values."""
PENDING = "pending"
APPROVED = "approved"
REJECTED = "rejected"
DISCONNECTED = "disconnected"
class PrivateLinkServiceConnectionProvisioningState(str, Enum):
"""Private endpoint connection provisioning states."""
CREATING = "creating"
RUNNING = "running"
DELETING = "deleting"
FAILED = "failed"
SUCCEEDED = "succeeded"
INCOMPLETE = "incomplete"
UPDATING = "updating"
CANCELED = "canceled"
class SharedPrivateLinkResourceStatus(str, Enum):
"""Shared private link resource status values."""
PENDING = "pending"
APPROVED = "approved"
REJECTED = "rejected"
DISCONNECTED = "disconnected"
class SharedPrivateLinkResourceProvisioningState(str, Enum):
"""Shared private link resource provisioning states."""
UPDATING = "updating"
DELETING = "deleting"
FAILED = "failed"
SUCCEEDED = "succeeded"
INCOMPLETE = "incomplete"Allow other Azure resources to connect privately to your search service:
# 1. Check supported private link resource types
supported = client.private_link_resources.list_supported("rg", "search-service")
# 2. Create private endpoint from another resource (typically done via ARM template or Portal)
# 3. Monitor and approve private endpoint connections
connections = client.private_endpoint_connections.list_by_service("rg", "search-service")
for conn in connections:
if conn.properties.private_link_service_connection_state.status == "Pending":
# Approve the connection
conn.properties.private_link_service_connection_state.status = "Approved"
conn.properties.private_link_service_connection_state.description = "Approved by automation"
updated_conn = client.private_endpoint_connections.update(
"rg", "search-service", conn.name, conn
)Allow your search service to connect privately to other Azure resources:
# Connect to Azure Storage for datasource operations
storage_connection = SharedPrivateLinkResource(
properties=SharedPrivateLinkResourceProperties(
private_link_resource_id="/subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.Storage/storageAccounts/storage",
group_id="blob",
request_message="Search service needs access to blob storage"
)
)
# Connect to Cosmos DB for datasource operations
cosmos_connection = SharedPrivateLinkResource(
properties=SharedPrivateLinkResourceProperties(
private_link_resource_id="/subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.DocumentDB/databaseAccounts/cosmos",
group_id="Sql",
request_message="Search service needs access to Cosmos DB"
)
)
# Create the connections
storage_op = client.shared_private_link_resources.begin_create_or_update(
"rg", "search-service", "storage-connection", storage_connection
)
cosmos_op = client.shared_private_link_resources.begin_create_or_update(
"rg", "search-service", "cosmos-connection", cosmos_connection
)
# Wait for completion and check status
storage_result = storage_op.result()
cosmos_result = cosmos_op.result()Install with Tessl CLI
npx tessl i tessl/pypi-azure-mgmt-search