Microsoft Azure Batch Management Client Library for Python
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Private endpoint connections and network security perimeter configuration for secure network access to Azure Batch resources.
Manages private endpoint connections for secure network access to Batch accounts.
def list_by_batch_account(
resource_group_name: str,
account_name: str,
maxresults: int = None,
**kwargs: Any
) -> ItemPaged[PrivateEndpointConnection]:
"""
Lists all private endpoint connections in the Batch account.
Args:
resource_group_name (str): The name of the resource group
account_name (str): The name of the Batch account
maxresults (int, optional): Maximum number of results to return
Returns:
ItemPaged[PrivateEndpointConnection]: List of private endpoint connections
"""
def get(
resource_group_name: str,
account_name: str,
private_endpoint_connection_name: str,
**kwargs: Any
) -> PrivateEndpointConnection:
"""
Gets information about the specified private endpoint connection.
Args:
resource_group_name (str): The name of the resource group
account_name (str): The name of the Batch account
private_endpoint_connection_name (str): The private endpoint connection identifier
Returns:
PrivateEndpointConnection: The private endpoint connection details
"""
def update(
resource_group_name: str,
account_name: str,
private_endpoint_connection_name: str,
parameters: PrivateEndpointConnection,
if_match: str = None,
**kwargs: Any
) -> LROPoller[PrivateEndpointConnection]:
"""
Updates the properties of an existing private endpoint connection.
Args:
resource_group_name (str): The name of the resource group
account_name (str): The name of the Batch account
private_endpoint_connection_name (str): The private endpoint connection identifier
parameters (PrivateEndpointConnection): Connection update parameters
if_match (str, optional): ETag value for conditional operations
Returns:
LROPoller[PrivateEndpointConnection]: Long-running operation poller
"""
def delete(
resource_group_name: str,
account_name: str,
private_endpoint_connection_name: str,
**kwargs: Any
) -> LROPoller[None]:
"""
Deletes the specified private endpoint connection.
Args:
resource_group_name (str): The name of the resource group
account_name (str): The name of the Batch account
private_endpoint_connection_name (str): The private endpoint connection identifier
Returns:
LROPoller[None]: Long-running operation poller for the deletion
"""Discovers available private link resources for creating private endpoints.
def list_by_batch_account(
resource_group_name: str,
account_name: str,
maxresults: int = None,
**kwargs: Any
) -> ItemPaged[PrivateLinkResource]:
"""
Lists the private link resources supported for the Batch account.
Args:
resource_group_name (str): The name of the resource group
account_name (str): The name of the Batch account
maxresults (int, optional): Maximum number of results to return
Returns:
ItemPaged[PrivateLinkResource]: List of private link resources
"""
def get(
resource_group_name: str,
account_name: str,
private_link_resource_name: str,
**kwargs: Any
) -> PrivateLinkResource:
"""
Gets information about the specified private link resource.
Args:
resource_group_name (str): The name of the resource group
account_name (str): The name of the Batch account
private_link_resource_name (str): The private link resource name
Returns:
PrivateLinkResource: The private link resource details
"""Manages network security perimeter configurations for advanced network isolation.
def list_configurations(
resource_group_name: str,
account_name: str,
**kwargs: Any
) -> ItemPaged[NetworkSecurityPerimeterConfiguration]:
"""
Lists all network security perimeter configurations in the Batch account.
Args:
resource_group_name (str): The name of the resource group
account_name (str): The name of the Batch account
Returns:
ItemPaged[NetworkSecurityPerimeterConfiguration]: List of NSP configurations
"""
def get_configuration(
resource_group_name: str,
account_name: str,
network_security_perimeter_configuration_name: str,
**kwargs: Any
) -> NetworkSecurityPerimeterConfiguration:
"""
Gets information about the specified network security perimeter configuration.
Args:
resource_group_name (str): The name of the resource group
account_name (str): The name of the Batch account
network_security_perimeter_configuration_name (str): The NSP configuration name
Returns:
NetworkSecurityPerimeterConfiguration: The NSP configuration details
"""
def reconcile_configuration(
resource_group_name: str,
account_name: str,
network_security_perimeter_configuration_name: str,
**kwargs: Any
) -> LROPoller[None]:
"""
Reconciles the specified network security perimeter configuration.
Args:
resource_group_name (str): The name of the resource group
account_name (str): The name of the Batch account
network_security_perimeter_configuration_name (str): The NSP configuration name
Returns:
LROPoller[None]: Long-running operation poller for reconciliation
"""class PrivateEndpointConnection:
id: str
name: str
type: str
etag: str
private_endpoint: PrivateEndpoint
private_link_service_connection_state: PrivateLinkServiceConnectionState
provisioning_state: PrivateEndpointConnectionProvisioningState
class PrivateEndpoint:
id: str
class PrivateLinkServiceConnectionState:
status: PrivateLinkServiceConnectionStatus
description: str
actions_required: str
class PrivateLinkResource:
id: str
name: str
type: str
properties: dict
group_id: str
required_members: list
required_zone_names: listclass NetworkSecurityPerimeterConfiguration:
id: str
name: str
type: str
properties: NetworkSecurityPerimeterConfigurationProperties
class NetworkSecurityPerimeterConfigurationProperties:
provisioning_state: NetworkSecurityPerimeterConfigurationProvisioningState
provisioning_issues: list
network_security_perimeter: NetworkSecurityPerimeter
resource_association: ResourceAssociation
profile: NetworkSecurityProfile
class NetworkSecurityPerimeter:
id: str
location: str
perimeter_guid: str
class NetworkSecurityProfile:
name: str
access_rules_version: int
access_rules: list
diagnostic_settings_version: int
enabled_log_categories: listclass PrivateEndpointConnectionProvisioningState:
SUCCEEDED = "Succeeded"
UPDATING = "Updating"
DELETING = "Deleting"
FAILED = "Failed"
class PrivateLinkServiceConnectionStatus:
PENDING = "Pending"
APPROVED = "Approved"
REJECTED = "Rejected"
DISCONNECTED = "Disconnected"
class NetworkSecurityPerimeterConfigurationProvisioningState:
SUCCEEDED = "Succeeded"
CREATING = "Creating"
UPDATING = "Updating"
DELETING = "Deleting"
ACCEPTED = "Accepted"
FAILED = "Failed"
CANCELED = "Canceled"# List all private endpoint connections
pe_connections = client.private_endpoint_connection.list_by_batch_account(
"my-resource-group",
"my-batch-account"
)
for connection in pe_connections:
print(f"Connection: {connection.name}")
print(f"Status: {connection.private_link_service_connection_state.status}")
print(f"Description: {connection.private_link_service_connection_state.description}")from azure.mgmt.batch.models import (
PrivateEndpointConnection,
PrivateLinkServiceConnectionState,
PrivateLinkServiceConnectionStatus
)
# Get existing connection
connection = client.private_endpoint_connection.get(
"my-resource-group",
"my-batch-account",
"my-private-endpoint-connection"
)
# Update connection state to approved
connection.private_link_service_connection_state = PrivateLinkServiceConnectionState(
status=PrivateLinkServiceConnectionStatus.APPROVED,
description="Approved by administrator"
)
# Apply the update
operation = client.private_endpoint_connection.update(
"my-resource-group",
"my-batch-account",
"my-private-endpoint-connection",
connection
)
updated_connection = operation.result()
print(f"Connection approved: {updated_connection.private_link_service_connection_state.status}")# List available private link resources
pl_resources = client.private_link_resource.list_by_batch_account(
"my-resource-group",
"my-batch-account"
)
for resource in pl_resources:
print(f"Resource: {resource.name}")
print(f"Group ID: {resource.group_id}")
print(f"Required members: {', '.join(resource.required_members)}")
if resource.required_zone_names:
print(f"Required zones: {', '.join(resource.required_zone_names)}")# List network security perimeter configurations
nsp_configs = client.network_security_perimeter.list_configurations(
"my-resource-group",
"my-batch-account"
)
for config in nsp_configs:
print(f"NSP Configuration: {config.name}")
print(f"Provisioning State: {config.properties.provisioning_state}")
if config.properties.provisioning_issues:
print("Provisioning Issues:")
for issue in config.properties.provisioning_issues:
print(f" - {issue.properties.issue_type}: {issue.properties.description}")# Reconcile a network security perimeter configuration
operation = client.network_security_perimeter.reconcile_configuration(
"my-resource-group",
"my-batch-account",
"my-nsp-configuration"
)
# Wait for reconciliation to complete
operation.result()
print("Network security perimeter reconciliation completed")def setup_private_endpoint_security(resource_group: str, account_name: str):
"""Set up private endpoint security for a Batch account."""
print(f"Setting up private endpoint security for {account_name}...")
# Discover available private link resources
print("\n1. Discovering private link resources...")
pl_resources = client.private_link_resource.list_by_batch_account(
resource_group, account_name
)
for resource in pl_resources:
print(f" Available: {resource.group_id}")
# List existing private endpoint connections
print("\n2. Checking existing connections...")
connections = client.private_endpoint_connection.list_by_batch_account(
resource_group, account_name
)
pending_connections = []
for connection in connections:
status = connection.private_link_service_connection_state.status
print(f" Connection {connection.name}: {status}")
if status == PrivateLinkServiceConnectionStatus.PENDING:
pending_connections.append(connection)
# Approve pending connections
if pending_connections:
print(f"\n3. Approving {len(pending_connections)} pending connections...")
for connection in pending_connections:
connection.private_link_service_connection_state.status = \
PrivateLinkServiceConnectionStatus.APPROVED
connection.private_link_service_connection_state.description = \
"Auto-approved by setup script"
operation = client.private_endpoint_connection.update(
resource_group, account_name, connection.name, connection
)
operation.result()
print(f" Approved: {connection.name}")
print("\nPrivate endpoint security setup complete!")
# Run setup
setup_private_endpoint_security("my-resource-group", "my-batch-account")Install with Tessl CLI
npx tessl i tessl/pypi-azure-mgmt-batch