Floci AZ

repository·main·Indexed 43 days ago

https://github.com/floci-io/floci-az

A lightweight, open-source local Azure emulator for development, testing, and CI/CD pipelines. It provides Azure-compatible services including Storage (Blob, Queue, Table), Functions, Cosmos DB, Key Vault, Event Hubs, and Service Bus on a unified port (4577) without requiring an Azure account or authentication tokens.

Tokens
89.5K
Snippets
196
Records
280
Agent score
60%

What's inside Floci AZ

  1. Overview of Microsoft Entra ID service

    main

    The Microsoft Entra ID service in Floci AZ is a local OpenID Connect (OIDC) provider that issues real RS256-signed JWTs. It includes a published discovery document and JWKS, allowing applications that acquire and validate Entra tokens to work fully offline.

    Key features include:

    • Signed tokens: RS256 JWTs with stable signing keys and unique uti identifiers.
    • Discovery & JWKS: Standard OIDC endpoints for configuration and public keys.
    • Supported Grants: client_credentials, password (ROPC), and authorization_code (with PKCE).
    • Azure-shaped errors: Error responses include error_description (with AADSTS codes), trace_id, and correlation_id to match real Azure behavior.
  2. Overview of Floci-AZ Emulated Azure Services

    main

    Floci-AZ provides emulation for a wide range of core Azure services. Services are categorized by their access pattern: some use specific URL path prefixes (e.g., /{account}-cosmos/), some use ARM (Azure Resource Manager) paths (e.g., Microsoft.Network), and others use specific protocols like AMQP or Kafka.

    Key service categories include:

    • Storage: Blob, Queue, Table, and Cosmos DB (SQL and multi-API).
    • Compute: Azure Functions, AKS (Kubernetes), Container Apps, and Virtual Machines.
    • Identity & Security: Microsoft Entra ID (OIDC), Key Vault, and Managed Identity.
    • Messaging: Event Hubs, Service Bus, and Event Grid.
    • Databases: Azure SQL, PostgreSQL, MySQL, and MariaDB.
    • Networking & Management: Virtual Network, API Management, and Azure Monitor.
  3. What is Floci-AZ?

    main

    Floci-AZ is a fast, free, and open-source local Azure service emulator. It provides a wide range of Azure services in a single native binary, including Blob Storage, Queues, Tables, Azure Functions, App Configuration, Cosmos DB (all APIs), Key Vault, Event Hubs, API Management, Virtual Network, Virtual Machines, Azure Cache for Redis, and Azure Container Registry.

    Key advantages over other emulators like Azurite or Functions Core Tools include:

    • Unified Port: All services are accessible via a single port (4577).
    • Fast Startup: Native image startup in <100ms.
    • Broad Service Coverage: Includes Cosmos DB (multiple APIs), Key Vault, and App Configuration which are missing in other tools.
    • Persistence Options: Supports various storage modes including WAL (Write-Ahead Logging) and hybrid persistence.
  4. What is Floci AZ?

    main

    Floci AZ is a free, open-source local Azure emulator designed for development, testing, and CI environments. It provides Azure-compatible services locally, allowing you to point your Azure SDK, CLI, or Terraform at http://localhost:4577 without requiring an Azure account, auth tokens, or paid feature gates.

    It is part of the Floci emulator family, which includes emulators for AWS, GCP, and OCI.

  5. Use Azure Container Registry (ACR) in floci-az

    main

    floci-az provides an Azure Container Registry (ACR) emulator compatible with the azure-mgmt-containerregistry SDK, az acr CLI, Terraform (azurerm_container_registry), and standard Docker clients.

    It supports two primary interaction modes:

    1. Management Plane (ARM): Via port 4577, used for lifecycle operations (create, get, update, delete, list) and credential management.
    2. Data Plane (Docker/OCI): Used for pushing and pulling images. This can be accessed via a zero-configuration anonymous HTTP port or via the Azure-native {name}.azurecr.io endpoint using Entra token exchange.
  6. Compare Floci AZ with official Azure local tools

    main

    Floci AZ provides a consolidated, lightweight alternative to official Azure local tools like Azurite and Functions Core Tools. It consolidates many Azure services onto a single port (4577) and uses a native image for sub-100ms startup times.

    Key Advantages

    • Unified Port: All services are accessible via port 4577.
    • Broad Service Support: Includes Blob, Queue, Table, Functions, App Configuration, Cosmos DB, Key Vault, Event Hubs, Service Bus, and more.
    • Native Performance: Starts in <100ms using a native image.
    • Storage Modes: Supports persistent, WAL, and Hybrid modes.
    • License: MIT licensed.
    FeatureFloci AZAzuriteFunctions Core Tools
    Blob/Queue/Table Storage✅✅❌
    Azure Functions✅❌✅
    Cosmos DB (SQL API)✅❌❌
    Key Vault / Event Hubs✅❌❌
    Native binary✅❌✅
    Unified port✅ (4577)❌❌
  7. Understand the Floci AZ Service Bus architecture

    main

    Floci AZ provides Azure Service Bus emulation using two distinct planes:

    1. Management Plane: An HTTP-based API used for entity topology (creating/deleting queues, topics, and subscriptions). It runs on port 4577 at the path /{account}-servicebus/.
    2. Data Plane: An AMQP 1.0 interface backed by an Apache ActiveMQ Artemis sidecar for sending and receiving messages. It runs on port 5673 (AMQP) or 5674 (AMQPS).

    Important: Mocked Mode By default, the emulator runs in mocked: true mode. In this mode, the management API is available, but the Artemis sidecar is not started, making the AMQP data plane unavailable. To send or receive messages, you must set mocked: false and ensure the AMQP ports are exposed.

  8. Understand Received Message Metadata

    main

    When receiving messages (via session receivers, dead-letter queues, ReceiveAndDelete, or streamed large messages), the following metadata is exposed:

    • SequenceNumber: Uses Artemis broker message IDs. Note that unlike Azure, sequence numbers may contain gaps, and moving a message to a dead-letter queue may assign a new ID.
    • EnqueuedTime: Matches the timestamp for the same message in the same entity during a peek operation. This value is preserved during abandon and lock-expiry redelivery, and during dead-lettering.
  9. Understand Per-entity Delivery Settings

    main

    Queues and subscriptions support Azure-compatible delivery settings. If these are omitted in the entity-create payload, the service falls back to the global defaults configured in the environment or application.yml.

    • MaxDeliveryCount: (1–2000) The number of delivery attempts before a message is moved to the dead-letter queue.
    • LockDuration: (up to PT5M) The duration for session locks and non-session peek-lock deliveries. If a lock expires, the message becomes available to other receivers. Late settlement attempts on expired locks will return MessageLockLost.
  10. Manage Snapshots for point-in-time configuration

    main

    Snapshots capture a frozen, immutable copy of a filtered set of key-values. This is useful for ensuring consistent configuration across a deployment.

    Lifecycle:

    1. Provisioning: Creating a snapshot is an asynchronous operation. PUT /snapshots/{name} returns a 201 with status: provisioning. SDKs use pollers (e.g., begin_create_snapshot) to wait for the status to become ready.
    2. Reading: Use listConfigurationSettingsForSnapshot (Java) or list_configuration_settings(snapshot_name=...) (Python) to read from the frozen set.
    3. Archive/Recover: You can move snapshots to an archived state or recover them to make them ready again.

    Composition Types: When creating a snapshot, you can choose how to handle overlapping keys:

    • key (default): Deduplicates by key. If multiple filters match the same key, the last one wins.
    • key_label: Keeps all unique (key, label) pairs without deduplication.

    Note: Changes to live key-values do not affect existing snapshots.

    from azure.appconfiguration import ConfigurationSettingsFilter, SnapshotComposition
    
    # Create a snapshot with specific composition
    created = client.begin_create_snapshot(
        name="all-envs",
        filters=[ConfigurationSettingsFilter(key="app/*", label="prod")],
        composition_type=SnapshotComposition.KEY_LABEL,
    ).result()
    
    # Read from it
    for s in client.list_configuration_settings(snapshot_name="all-envs"):
        print(f"{s.key} = {s.value}")
  11. Use Labels for environment-specific settings

    main

    Labels allow you to maintain different values for the same key based on the environment (e.g., prod vs dev).

    When setting a value, provide a label. When retrieving a value, specify the label to ensure you get the correct environment-specific setting. If no label is specified during retrieval, the behavior depends on the SDK, but typically you must provide the label to disambiguate keys that share the same name but have different labels.

    # Python: Using labels
    client.set_configuration_setting(ConfigurationSetting(key="timeout", value="30", label="prod"))
    client.set_configuration_setting(ConfigurationSetting(key="timeout", value="5",  label="dev"))
    
    # Fetch by label
    prod = client.get_configuration_setting("timeout", label_filter="prod").value  # "30"
  12. Configure Subscription Rules and Filters

    main

    Subscriptions use rules to filter messages. Floci AZ supports the following filter types:

    • CorrelationFilter: Exact-match (case-sensitive) AND-combination over CorrelationId, Label/Subject, SessionId, and application properties.
    • SqlFilter: SQL92 expressions over application properties and sys.* system properties (e.g., sys.CorrelationId, sys.Label). Supports LIKE, IN, BETWEEN, IS NULL, etc.
    • TrueFilter / FalseFilter: Accept-all or accept-none.

    Important Constraints & Deviations:

    • Unsupported Filters: Filters on MessageId, To, ReplyTo, ReplyToSessionId, or ContentType (and their sys.* forms) are rejected with HTTP 400 because these AMQP fields have no broker-side selector mapping.
    • Rule Actions: SqlRuleAction properties are stored/echoed but not applied to delivered messages.
    • Logical OR: Multiple rules on a single subscription combine as a logical OR.
    • Case Sensitivity: Property names in filters are case-sensitive.