Python client library for managing Azure Maps resources through the Azure Resource Manager
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Complete lifecycle management of Azure Maps accounts including creation, configuration, updates, and deletion. This module also handles authentication keys, SAS tokens, CORS configuration, encryption settings, and managed identities.
Create new Azure Maps accounts or update existing ones with full configuration options including SKU, location, identity, and properties.
def create_or_update(
resource_group_name: str,
account_name: str,
maps_account: Union[MapsAccount, IO],
**kwargs
) -> MapsAccount:
"""
Create or update an Azure Maps account.
Args:
resource_group_name: Name of the resource group
account_name: Name of the Maps account
maps_account: Maps account object or JSON payload
Returns:
MapsAccount: The created or updated account
Raises:
HttpResponseError: If the request fails
"""
def update(
resource_group_name: str,
account_name: str,
maps_account_update_parameters: Union[MapsAccountUpdateParameters, IO],
**kwargs
) -> MapsAccount:
"""
Update an existing Azure Maps account.
Args:
resource_group_name: Name of the resource group
account_name: Name of the Maps account
maps_account_update_parameters: Update parameters
Returns:
MapsAccount: The updated account
"""Usage example:
from azure.mgmt.maps.models import (
MapsAccount, Sku, Kind, MapsAccountProperties,
CorsRules, CorsRule, ManagedServiceIdentity, ManagedServiceIdentityType
)
from typing import Union, IO
# Create account with Gen2 features
maps_account = MapsAccount(
location="eastus",
sku=Sku(name="S1"), # Standard tier
kind=Kind.GEN2,
properties=MapsAccountProperties(
disable_local_auth=False,
cors=CorsRules(cors_rules=[
CorsRule(
allowed_origins=["https://example.com"],
allowed_methods=["GET", "POST"],
allowed_headers=["*"],
max_age_in_seconds=3600
)
])
),
tags={"environment": "production", "team": "geo"}
)
account = client.accounts.create_or_update(
resource_group_name="my-rg",
account_name="my-maps-account",
maps_account=maps_account
)Delete accounts or retrieve detailed information about existing accounts.
def delete(resource_group_name: str, account_name: str, **kwargs) -> None:
"""
Delete an Azure Maps account.
Args:
resource_group_name: Name of the resource group
account_name: Name of the Maps account to delete
Raises:
HttpResponseError: If the request fails
"""
def get(resource_group_name: str, account_name: str, **kwargs) -> MapsAccount:
"""
Get details of an Azure Maps account.
Args:
resource_group_name: Name of the resource group
account_name: Name of the Maps account
Returns:
MapsAccount: The account details
"""List and discover Maps accounts within resource groups or across subscriptions.
def list_by_resource_group(resource_group_name: str, **kwargs) -> Iterable[MapsAccount]:
"""
List Maps accounts in a resource group.
Args:
resource_group_name: Name of the resource group
Returns:
Iterable[MapsAccount]: Iterator of Maps accounts
"""
def list_by_subscription(**kwargs) -> Iterable[MapsAccount]:
"""
List Maps accounts in the subscription.
Returns:
Iterable[MapsAccount]: Iterator of Maps accounts
"""Usage example:
# List all accounts in subscription
all_accounts = list(client.accounts.list_by_subscription())
# List accounts in specific resource group
rg_accounts = list(client.accounts.list_by_resource_group("my-rg"))
for account in all_accounts:
print(f"Account: {account.name} in {account.location}")
print(f"SKU: {account.sku.name}, Kind: {account.kind}")Manage primary and secondary access keys for Maps accounts, including key regeneration.
def list_keys(resource_group_name: str, account_name: str, **kwargs) -> MapsAccountKeys:
"""
Get the access keys for a Maps account.
Args:
resource_group_name: Name of the resource group
account_name: Name of the Maps account
Returns:
MapsAccountKeys: Object containing primary and secondary keys
"""
def regenerate_keys(
resource_group_name: str,
account_name: str,
key_specification: Union[MapsKeySpecification, IO],
**kwargs
) -> MapsAccountKeys:
"""
Regenerate access keys for a Maps account.
Args:
resource_group_name: Name of the resource group
account_name: Name of the Maps account
key_specification: Specification of which key to regenerate
Returns:
MapsAccountKeys: Object with the new keys
"""Usage example:
from azure.mgmt.maps.models import MapsKeySpecification, KeyType
# Get current keys
keys = client.accounts.list_keys("my-rg", "my-account")
print(f"Primary: {keys.primary_key}")
print(f"Secondary: {keys.secondary_key}")
print(f"Primary last updated: {keys.primary_key_last_updated}")
print(f"Secondary last updated: {keys.secondary_key_last_updated}")
# Regenerate primary key
key_spec = MapsKeySpecification(key_type=KeyType.PRIMARY)
new_keys = client.accounts.regenerate_keys(
"my-rg",
"my-account",
key_spec
)
print(f"New primary key: {new_keys.primary_key}")Generate Shared Access Signature (SAS) tokens for secure, time-limited access to Maps services.
def list_sas(
resource_group_name: str,
account_name: str,
maps_account_sas_parameters: Union[AccountSasParameters, IO],
**kwargs
) -> MapsAccountSasToken:
"""
Create a SAS token for the Maps account.
Args:
resource_group_name: Name of the resource group
account_name: Name of the Maps account
maps_account_sas_parameters: SAS token parameters
Returns:
MapsAccountSasToken: Object containing the SAS token
"""Usage example:
from azure.mgmt.maps.models import AccountSasParameters, SigningKey
from datetime import datetime, timedelta
# Create SAS token valid for 24 hours
start_time = datetime.utcnow()
expiry_time = start_time + timedelta(hours=24)
sas_params = AccountSasParameters(
signing_key=SigningKey.PRIMARY_KEY,
principal_id="user-principal-id",
max_rate_per_second=500,
start=start_time.isoformat() + "Z",
expiry=expiry_time.isoformat() + "Z",
regions=["eastus", "westus2"]
)
sas_token = client.accounts.list_sas(
"my-rg",
"my-account",
sas_params
)
print(f"SAS Token: {sas_token.account_sas_token}")class MapsAccount:
"""Complete Azure Maps account resource."""
# Azure resource properties
id: Optional[str] # Resource ID
name: Optional[str] # Account name
type: Optional[str] # Resource type
location: Optional[str] # Azure region
tags: Optional[Dict[str, str]] # Resource tags
# Maps-specific configuration
sku: Optional[Sku] # Pricing tier
kind: Optional[Union[str, Kind]] # Account generation
identity: Optional[ManagedServiceIdentity] # Managed identity
properties: Optional[MapsAccountProperties] # Account properties
system_data: Optional[SystemData] # System metadata
class MapsAccountProperties:
"""Detailed account properties and configuration."""
# Authentication settings
disable_local_auth: Optional[bool] # Disable key-based auth
# Network and security
cors: Optional[CorsRules] # CORS configuration
encryption: Optional[Encryption] # Encryption settings
linked_resources: Optional[List[LinkedResource]] # Linked resources
# Account metadata (read-only)
unique_id: Optional[str] # Unique account identifier
provisioning_state: Optional[str] # Provisioning status
class MapsAccountUpdateParameters:
"""Parameters for updating Maps accounts."""
identity: Optional[ManagedServiceIdentity]
properties: Optional[MapsAccountProperties]
sku: Optional[Sku]
tags: Optional[Dict[str, str]]class Sku:
"""Maps account pricing tier configuration."""
name: Union[str, Name] # SKU name (S0, S1, G2)
tier: Optional[str] # Pricing tier
class Name(str, Enum):
"""Available SKU names."""
S0 = "S0" # Free tier
S1 = "S1" # Standard tier
G2 = "G2" # Gen2 tierclass ManagedServiceIdentity:
"""Managed identity configuration."""
type: Optional[Union[str, ManagedServiceIdentityType]]
user_assigned_identities: Optional[Dict[str, UserAssignedIdentity]]
principal_id: Optional[str] # Read-only
tenant_id: Optional[str] # Read-only
class Encryption:
"""Account encryption configuration."""
customer_managed_key_encryption: Optional[CustomerManagedKeyEncryption]
infrastructure_encryption: Optional[Union[str, InfrastructureEncryption]]
class CorsRules:
"""CORS configuration for web applications."""
cors_rules: Optional[List[CorsRule]]
class CorsRule:
"""Individual CORS rule."""
allowed_origins: List[str] # Required: Allowed origin domains or "*" for allInstall with Tessl CLI
npx tessl i tessl/pypi-azure-mgmt-maps