Skip to content

Azure

Validated types for Microsoft Azure resource identifiers.

Azure cloud resource types.

Modules:

  • compute

    Azure compute types.

  • containers

    Azure container types.

  • database

    Azure database types.

  • identity

    Azure identity types.

  • keyvault

    Azure Key Vault types.

  • messaging

    Azure messaging types.

  • region

    Azure region types.

  • resource

    Azure Resource ID type.

  • storage

    Azure storage types.

Classes:

  • BlobStorageUri

    Azure Blob Storage URI (https://{account}.blob.core.windows.net/{container}/{blob}).

  • KeyVaultUri

    Azure Key Vault URI (https://{vault_name}.vault.azure.net/).

  • Region

    Azure region identifiers.

  • ResourceId

    Azure Resource ID with support for nested resources.

Attributes:

AksClusterName module-attribute

AksClusterName = Annotated[str, AfterValidator(_validate_aks_cluster_name), WithJsonSchema({'type': 'string', 'pattern': '^[a-zA-Z0-9]([a-zA-Z0-9_-]{0,61}[a-zA-Z0-9])?$', 'description': 'Azure AKS cluster name.', 'examples': ['my-aks-cluster'], 'title': 'AksClusterName'})]

Azure AKS cluster name (e.g. my-aks-cluster).

ApiManagementName module-attribute

ApiManagementName = Annotated[str, AfterValidator(_validate_api_management_name), WithJsonSchema({'type': 'string', 'pattern': '^[a-zA-Z]([a-zA-Z0-9-]{0,48}[a-zA-Z0-9])?$', 'description': 'Azure API Management name.', 'examples': ['my-apim'], 'title': 'ApiManagementName'})]

Azure API Management name (e.g. my-apim).

AppServiceName module-attribute

AppServiceName = Annotated[str, AfterValidator(_validate_app_service_name), WithJsonSchema({'type': 'string', 'pattern': '^[a-zA-Z0-9]([a-zA-Z0-9-]{0,57}[a-zA-Z0-9])?$', 'description': 'Azure App Service name.', 'examples': ['my-app-service'], 'title': 'AppServiceName'})]

Azure App Service name (e.g. my-app-service).

ContainerAppName module-attribute

ContainerAppName = Annotated[str, AfterValidator(_validate_container_app_name), WithJsonSchema({'type': 'string', 'pattern': '^[a-z]([a-z0-9-]{0,29}[a-z0-9])?$', 'description': 'Azure Container App name.', 'examples': ['my-container-app'], 'title': 'ContainerAppName'})]

Azure Container App name (e.g. my-container-app).

ContainerRegistryName module-attribute

ContainerRegistryName = Annotated[str, AfterValidator(_validate_container_registry_name), WithJsonSchema({'type': 'string', 'pattern': '^[a-zA-Z0-9]{5,50}$', 'description': 'Azure Container Registry name.', 'examples': ['mycontainerregistry'], 'title': 'ContainerRegistryName', 'minLength': 5, 'maxLength': 50})]

Azure Container Registry name (e.g. mycontainerregistry).

CosmosDbAccountName module-attribute

CosmosDbAccountName = Annotated[str, AfterValidator(_validate_cosmos_db_account_name), WithJsonSchema({'type': 'string', 'pattern': '^[a-z0-9][a-z0-9-]{1,42}[a-z0-9]$', 'description': 'Azure Cosmos DB account name.', 'examples': ['my-cosmos-account'], 'title': 'CosmosDbAccountName'})]

Azure Cosmos DB account name (e.g. my-cosmos-account).

DataFactoryName module-attribute

DataFactoryName = Annotated[str, AfterValidator(_validate_data_factory_name), WithJsonSchema({'type': 'string', 'pattern': '^[a-zA-Z0-9](?!.*--)[a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$', 'description': 'Azure Data Factory name.', 'examples': ['my-data-factory'], 'title': 'DataFactoryName'})]

Azure Data Factory name (e.g. my-data-factory).

DatabricksWorkspaceName module-attribute

DatabricksWorkspaceName = Annotated[str, AfterValidator(_validate_databricks_workspace_name), WithJsonSchema({'type': 'string', 'pattern': '^[a-zA-Z0-9][a-zA-Z0-9_-]{1,62}[a-zA-Z0-9]$', 'description': 'Azure Databricks workspace name.', 'examples': ['my-databricks-ws'], 'title': 'DatabricksWorkspaceName'})]

Azure Databricks workspace name (e.g. my-databricks-ws).

EventHubNamespaceName module-attribute

EventHubNamespaceName = Annotated[str, AfterValidator(_validate_event_hub_namespace_name), WithJsonSchema({'type': 'string', 'pattern': '^[a-zA-Z][a-zA-Z0-9-]{4,48}[a-zA-Z0-9]$', 'description': 'Azure Event Hub namespace name.', 'examples': ['my-eventhub-ns'], 'title': 'EventHubNamespaceName'})]

Azure Event Hub namespace name (e.g. my-eventhub-ns).

FunctionAppName module-attribute

FunctionAppName = Annotated[str, AfterValidator(_validate_function_app_name), WithJsonSchema({'type': 'string', 'pattern': '^[a-zA-Z0-9][a-zA-Z0-9-]{0,58}[a-zA-Z0-9]$', 'description': 'Azure Function App name.', 'examples': ['my-function-app'], 'title': 'FunctionAppName'})]

Azure Function App name (e.g. my-function-app).

KeyVaultName module-attribute

KeyVaultName = Annotated[str, AfterValidator(_validate_key_vault_name), WithJsonSchema({'type': 'string', 'pattern': '^[a-zA-Z](?!.*--)[a-zA-Z0-9-]{1,22}[a-zA-Z0-9]$', 'description': 'Azure Key Vault name.', 'examples': ['my-key-vault'], 'title': 'KeyVaultName'})]

Azure Key Vault name (e.g. my-key-vault).

KeyVaultSecretName module-attribute

KeyVaultSecretName = Annotated[str, AfterValidator(_validate_key_vault_secret_name), WithJsonSchema({'type': 'string', 'pattern': '^[a-zA-Z0-9-]{1,127}$', 'description': 'Azure Key Vault secret name.', 'examples': ['my-secret'], 'title': 'KeyVaultSecretName', 'maxLength': 127})]

Azure Key Vault secret name (e.g. my-secret).

LogAnalyticsWorkspaceName module-attribute

LogAnalyticsWorkspaceName = Annotated[str, AfterValidator(_validate_log_analytics_workspace_name), WithJsonSchema({'type': 'string', 'pattern': '^[a-zA-Z0-9][a-zA-Z0-9-]{2,61}[a-zA-Z0-9]$', 'description': 'Azure Log Analytics workspace name.', 'examples': ['my-log-analytics'], 'title': 'LogAnalyticsWorkspaceName'})]

Azure Log Analytics workspace name (e.g. my-log-analytics).

RedisCacheName module-attribute

RedisCacheName = Annotated[str, AfterValidator(_validate_redis_cache_name), WithJsonSchema({'type': 'string', 'pattern': '^[a-zA-Z0-9](?!.*--)[a-zA-Z0-9-]{0,61}[a-zA-Z0-9]$', 'description': 'Azure Redis Cache name.', 'examples': ['my-redis-cache'], 'title': 'RedisCacheName'})]

Azure Redis Cache name (e.g. my-redis-cache).

ResourceGroupName module-attribute

ResourceGroupName = Annotated[str, AfterValidator(_validate_resource_group_name), WithJsonSchema({'type': 'string', 'pattern': '^[a-zA-Z0-9_\\-.()]{1,90}$', 'description': 'Azure Resource Group name.', 'examples': ['my-resource-group'], 'title': 'ResourceGroupName'})]

Azure Resource Group name (e.g. my-resource-group).

ServiceBusNamespace module-attribute

ServiceBusNamespace = Annotated[str, AfterValidator(_validate_service_bus_namespace), WithJsonSchema({'type': 'string', 'pattern': '^[a-zA-Z][a-zA-Z0-9-]{4,48}[a-zA-Z0-9]$', 'description': 'Azure Service Bus namespace.', 'examples': ['my-servicebus-ns'], 'title': 'ServiceBusNamespace'})]

Azure Service Bus namespace (e.g. my-servicebus-ns).

SqlServerName module-attribute

SqlServerName = Annotated[str, AfterValidator(_validate_sql_server_name), WithJsonSchema({'type': 'string', 'pattern': '^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$', 'description': 'Azure SQL Server name.', 'examples': ['my-sql-server'], 'title': 'SqlServerName'})]

Azure SQL Server name (e.g. my-sql-server).

StorageAccountName module-attribute

StorageAccountName = Annotated[str, AfterValidator(_validate_storage_account_name), WithJsonSchema({'type': 'string', 'pattern': '^[a-z0-9]{3,24}$', 'description': 'Azure Storage account name.', 'examples': ['mystorageaccount'], 'title': 'StorageAccountName', 'minLength': 3, 'maxLength': 24})]

Azure Storage account name (e.g. mystorageaccount).

SubscriptionId module-attribute

SubscriptionId = Annotated[str, AfterValidator(_validate_subscription_id), WithJsonSchema({'type': 'string', 'pattern': '^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$', 'description': 'Azure Subscription ID (UUID).', 'examples': ['12345678-1234-1234-1234-123456789012'], 'title': 'SubscriptionId'})]

Azure Subscription ID (UUID) (e.g. 12345678-1234-1234-1234-123456789012).

TenantId module-attribute

TenantId = Annotated[str, AfterValidator(_validate_tenant_id), WithJsonSchema({'type': 'string', 'pattern': '^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$', 'description': 'Azure Tenant ID (UUID).', 'examples': ['12345678-1234-1234-1234-123456789012'], 'title': 'TenantId'})]

Azure Tenant ID (UUID) (e.g. 12345678-1234-1234-1234-123456789012).

BlobStorageUri

Bases: CloudStorageUri

Azure Blob Storage URI (https://{account}.blob.core.windows.net/{container}/{blob}).

Methods:

__get_pydantic_core_schema__ classmethod

__get_pydantic_core_schema__(source_type: Any, handler: GetCoreSchemaHandler) -> CoreSchema

Return the Pydantic core schema for BlobStorageUri.

Source code in src/pydantypes/cloud/azure/storage.py
@classmethod
def __get_pydantic_core_schema__(
    cls, source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema:
    """Return the Pydantic core schema for BlobStorageUri."""
    return _str_type_core_schema(cls, source_type, handler)

__get_pydantic_json_schema__ classmethod

__get_pydantic_json_schema__(_core_schema: CoreSchema, handler: GetJsonSchemaHandler) -> JsonSchemaValue

Return the JSON schema for BlobStorageUri.

Source code in src/pydantypes/cloud/azure/storage.py
@classmethod
def __get_pydantic_json_schema__(
    cls, _core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue:
    """Return the JSON schema for BlobStorageUri."""
    return {
        "type": "string",
        "format": "azure-blob-storage-uri",
        "pattern": cls._pattern.pattern,
        "description": "Azure Blob Storage URI.",
        "examples": ["https://myaccount.blob.core.windows.net/mycontainer/path/to/blob"],
        "title": "BlobStorageUri",
    }

__new__

__new__(value: str) -> BlobStorageUri

Create and validate a new BlobStorageUri instance.

Source code in src/pydantypes/cloud/azure/storage.py
def __new__(cls, value: str) -> BlobStorageUri:
    """Create and validate a new BlobStorageUri instance."""
    m = cls._pattern.match(value)
    if not m:
        raise PydanticCustomError(
            "azure_blob_storage_uri",
            "Invalid Azure Blob Storage URI: {value}",
            {"value": value},
        )
    instance = str.__new__(cls, value)
    instance.account_name = m.group(1)
    instance.container = m.group(2)
    instance.bucket = m.group(2)
    instance.blob_path = m.group(3) or ""
    instance.key = m.group(3) or ""
    return instance

KeyVaultUri

Bases: str

Azure Key Vault URI (https://{vault_name}.vault.azure.net/).

Methods:

__get_pydantic_core_schema__ classmethod

__get_pydantic_core_schema__(source_type: Any, handler: GetCoreSchemaHandler) -> CoreSchema

Return the Pydantic core schema for KeyVaultUri.

Source code in src/pydantypes/cloud/azure/keyvault.py
@classmethod
def __get_pydantic_core_schema__(
    cls, source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema:
    """Return the Pydantic core schema for KeyVaultUri."""
    return _str_type_core_schema(cls, source_type, handler)

__get_pydantic_json_schema__ classmethod

__get_pydantic_json_schema__(_core_schema: CoreSchema, handler: GetJsonSchemaHandler) -> JsonSchemaValue

Return the JSON schema for KeyVaultUri.

Source code in src/pydantypes/cloud/azure/keyvault.py
@classmethod
def __get_pydantic_json_schema__(
    cls, _core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue:
    """Return the JSON schema for KeyVaultUri."""
    return {
        "type": "string",
        "format": "azure-key-vault-uri",
        "pattern": cls._pattern.pattern,
        "description": "Azure Key Vault URI.",
        "examples": ["https://my-vault.vault.azure.net/"],
        "title": "KeyVaultUri",
    }

__new__

__new__(value: str) -> KeyVaultUri

Create and validate a new KeyVaultUri instance.

Source code in src/pydantypes/cloud/azure/keyvault.py
def __new__(cls, value: str) -> KeyVaultUri:
    """Create and validate a new KeyVaultUri instance."""
    m = cls._pattern.match(value)
    if not m:
        raise PydanticCustomError(
            "azure_key_vault_uri",
            "Invalid Azure Key Vault URI: {value}",
            {"value": value},
        )
    instance = str.__new__(cls, value)
    instance.vault_name = m.group(1)
    return instance

Region

Bases: StrEnum

Azure region identifiers.

ResourceId

Bases: str

Azure Resource ID with support for nested resources.

Methods:

__get_pydantic_core_schema__ classmethod

__get_pydantic_core_schema__(source_type: Any, handler: GetCoreSchemaHandler) -> CoreSchema

Return the Pydantic core schema for ResourceId.

Source code in src/pydantypes/cloud/azure/resource.py
@classmethod
def __get_pydantic_core_schema__(
    cls, source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema:
    """Return the Pydantic core schema for ResourceId."""
    return _str_type_core_schema(cls, source_type, handler)

__get_pydantic_json_schema__ classmethod

__get_pydantic_json_schema__(_core_schema: CoreSchema, handler: GetJsonSchemaHandler) -> JsonSchemaValue

Return the JSON schema for ResourceId.

Source code in src/pydantypes/cloud/azure/resource.py
@classmethod
def __get_pydantic_json_schema__(
    cls, _core_schema: CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue:
    """Return the JSON schema for ResourceId."""
    return {
        "type": "string",
        "format": "azure-resource-id",
        "pattern": cls._pattern.pattern,
        "description": "Azure Resource ID.",
        "examples": [
            "/subscriptions/12345678-1234-1234-1234-123456789012"
            "/resourceGroups/myRG/providers/Microsoft.Compute/virtualMachines/myVM"
        ],
        "title": "ResourceId",
    }

__new__

__new__(value: str) -> ResourceId

Create and validate a new ResourceId instance.

Source code in src/pydantypes/cloud/azure/resource.py
def __new__(cls, value: str) -> ResourceId:
    """Create and validate a new ResourceId instance."""
    m = cls._pattern.match(value)
    if not m:
        raise PydanticCustomError(
            "azure_resource_id",
            "Invalid Azure Resource ID: {value}",
            {"value": value},
        )
    path = m.group(4)
    segments = path.strip("/").split("/")
    if len(segments) % 2 != 0:
        raise PydanticCustomError(
            "azure_resource_id",
            "Invalid Azure Resource ID: malformed resource path in {value}",
            {"value": value},
        )
    instance = str.__new__(cls, value)
    instance.subscription_id = m.group(1)
    instance.resource_group = m.group(2)
    instance.provider_namespace = m.group(3)
    instance.resource_path = path
    instance.resource_type = segments[-2]
    instance.resource_name = segments[-1]
    return instance