Introducing a new way to review your PRs.

Read the announcement

floci-io / floci-az

Light, fluffy, and always free - Local Azure Emulator

View on GitHub

27 documents · Updated Nov 23, 2026

docs / cloud-directory-configuration

Cloud and directory configuration

Cloud and directory configuration gives the emulator a consistent Azure world. It selects the cloud and DNS rules for each tenant, resolves the scope of each request, and supplies the tenant, subscription, and resource-group state that management-plane services use. See Core routing and auth for the wider request path, ARM resource governance for resource access rules, and management groups for hierarchy behavior. See ARM deployments for deployment scope and emulator console for operational access.

Cloud profiles

The cloud catalog describes the Azure public, US Government, and China clouds. A cloud profile supplies the service endpoints, token audiences, DNS suffixes, regions, and metadata endpoint data that clients need to address that cloud. The bundled catalog is the source for these values, while floci-az.cloud.default selects the fallback profile. EmulatorConfig and CloudCatalog define this relationship.

Default locations

Default locations give resources a valid region when a request does not name one. A per-cloud default-location setting overrides the catalog default after the value is normalized to the cloud's canonical location name. The setting must name a cloud in the catalog and a location that cloud offers, so invalid resource placement fails during startup rather than on a later write. CloudDefaults and CloudDefaults define this selection.

References: src/…/CloudDefaults.java• L12-18 src/…/CloudDefaults.java• L24-55 src/…/CloudCatalog.java• L81-97

DNS suffix selection

DNS suffix selection maps a service host to a cloud and service. Matching ignores case, a port, and a final dot. The resolver checks the longest known suffix first, so a specific service suffix wins over a shorter suffix. This lets host-routed services and response URLs use the same cloud profile.

The suffix catalog covers host-addressed services such as storage, Key Vault, Service Bus, container apps, communication services, and Azure AI Search. Each known suffix records whether request routing may use the Host header for that service. Other suffixes only build hostnames in responses. A suffix with no trusted local value stays marked as unsettled instead of being silently guessed. The catalog includes the Azure AI Search suffix for the public, US Government, and China clouds, and marks Search as host-routed. CloudProfile, CloudCatalog, and CloudSuffix describe the contract.

References: src/…/CloudCatalog.java• L60-77 src/…/CloudCatalog.java• L262-275 src/…/CloudCatalog.java• L337-357 src/…/CloudProfile.java• L53-65 src/…/CloudSuffix.java• L3-46 src/…/clouds.json• L848-852 src/…/clouds.json• L1216-1220 src/…/clouds.json• L1583-1587

Cloud metadata responses

Cloud metadata responses adapt the selected cloud profile for clients that discover Azure endpoints. The emulator advertises one cloud named floci-az and replaces client-facing resource manager, portal, gallery, login, and token-audience endpoints with its own base URL. It keeps the catalog's cloud data for services that clients do not reach through the metadata response. CloudMetadata and CloudMetadata define this boundary.

References: src/…/CloudMetadata.java• L8-25 src/…/CloudMetadata.java• L37-73

Startup validation

Startup validation loads the bundled cloud catalog and resolves every cloud's effective default location before the emulator serves requests. The catalog rejects incomplete cloud records, missing required suffix entries, duplicate cloud names, and duplicate settled suffix ownership. A malformed catalog, an unknown configured cloud, or a configured location that the cloud does not offer stops startup rather than allowing a later request to use incomplete endpoint or location data. The startup log lists each available cloud, its location count, and its selected default. CloudStartupValidator, CloudDefaults, and CloudCatalog provide these checks.

References: src/…/CloudStartupValidator.java• L25-35 src/…/CloudDefaults.java• L29-43 src/…/CloudCatalog.java• L103-177 src/…/CloudCatalog.java• L294-357 src/…/clouds.json• L1-30

Request scope resolution

Request scope resolution identifies the cloud and any named tenant, subscription, or resource group before a handler processes the request. It records the result on the request so routing, authentication, and ARM rules can use one shared view of the request. Resolution reports what it found; the ARM request gate decides whether an unknown or mismatched scope is allowed.

Resolution precedence

The resolver uses the strongest request signal first. An ARM subscription path has priority because it names the management scope directly. For an unknown subscription, tenant scoping can use the caller's token tenant when that tenant exists; otherwise the default tenant owns the first-use scope. The resolver reads the token tenant only when tenant scoping or strict token checks are enabled. An Entra path then identifies a tenant. Host suffixes and known cloud hosts identify cloud-only requests. If no signal applies, the configured default cloud is used.

The resolution order is:

  1. An ARM path with a subscription, then that subscription's tenant and cloud.
  2. An Entra path with a tenant segment.
  3. A known Azure service DNS suffix.
  4. An owned data-plane name when a name registry provides one.
  5. A catalog ARM or login host.
  6. The configured default cloud.

This precedence keeps a subscription path authoritative even when the request host points at a different cloud. The resolver only records this scope. It does not reject a tenant or subscription mismatch. Entra aliases such as common, organizations, and consumers do not name a tenant, so they fall through to later signals. ScopeResolver and ScopeResolver define the signals, token-tenant gate, and order.

References: src/…/ScopeResolver.java• L21-47 src/…/ScopeResolver.java• L123-171 src/…/ScopeSource.java• L3-17

Request scope context

The resolved scope contains the cloud, tenant, subscription, resource group, token tenant when available, and the signal that selected the cloud. The routing filter resolves it once and carries it with the request. This avoids different handlers making different cloud choices during one request, including requests that run on a blocking worker. ScopeContext and AzureRequest define the carried state.

The request flow is:

flowchart LR
    A[Incoming request] --> B[Read path and host]
    B --> C[Resolve cloud and ARM scope]
    C --> D[Attach scope to request]
    D --> E[Authenticate and apply ARM rules]
    E --> F[Dispatch to service]

References: src/…/AzureRoutingFilter.java• L34-79 src/…/AzureRequest.java• L95-125 src/…/ScopeContext.java• L3-16

Directory state

The directory is the shared record of which tenants and subscriptions exist, which cloud owns each tenant, and which subscription belongs to each tenant. ARM and identity services use it to make listings, IDs, and scope checks agree. IDs are compared without case, while the original spelling remains available for responses.

Seeded tenants and subscriptions

The directory always starts with one default tenant and one default subscription. The default IDs come from services.entra.default-tenant-id and services.arm.default-subscription-id. Additional tenants and subscriptions come from floci-az.tenants and floci-az.subscriptions in configuration. A tenant may select a cloud, and a subscription may select an existing tenant and a state.

Configuration is checked as a group. Cloud names, IDs, subscription states, duplicate entries, and tenant references must be valid before the directory can start. A configured entry with a default ID replaces that default entry's display or ownership data.

Directory itemMain relationshipDefault behavior
TenantOwns subscriptions and lives in one cloudDefault display name and floci-az.local domain
SubscriptionBelongs to one directory tenant and has a stateEnabled under the default tenant
First-use subscriptionRegisters an unknown subscription when policy allows itUses the named tenant when known, otherwise the default tenant

DirectorySeed and EmulatorConfig define the seed model. Tenant and Subscription define the directory records.

References: src/…/DirectorySeed.java• L42-103 src/…/EmulatorConfig.java• L54-66 src/…/Tenant.java• L5-16 src/…/Subscription.java• L5-16

First-use registration

When subscription strictness is off, an ARM request can register a subscription that the directory does not yet hold. The new subscription is enabled and is stored under a known tenant when possible. When strict subscription behavior is on, the ARM rules reject the unknown subscription instead. The parity level and its override choose between these behaviors.

First-use entries keep their registration order until a restart. In a persistent storage mode they survive restart. Seeded and configured tenant and subscription entries are rewritten from current configuration at each start. Entries that are no longer seeded or configured are removed, while restored first-use subscriptions whose tenant no longer exists move to the current default tenant. This keeps the directory from reporting an owner that tenant listings do not contain. AzureDirectory and AzureDirectory own this lifecycle.

References: src/…/AzureDirectory.java• L27-41 src/…/AzureDirectory.java• L127-149 src/…/AzureDirectory.java• L179-257 src/…/EmulatorConfig.java• L78-94

Provider registration state

Provider registration state records whether a subscription may use a resource provider namespace. The default depends on provider strictness: normal mode treats every namespace as registered, while strict mode starts untouched namespaces as not registered. Register and unregister actions then set an explicit state that provider APIs can report.

Microsoft.Resources is always registration-free. Other namespace states use the subscription and namespace as a case-insensitive pair. In strict mode, explicit states share the directory store and survive restart; reset clears them with the rest of directory state. The service reports final Registered, NotRegistered, or Unregistered states instead of Azure's transitional states. ProviderRegistrations and RegistrationState define this behavior.

References: src/…/ProviderRegistrations.java• L19-27 src/…/ProviderRegistrations.java• L56-82 src/…/ProviderRegistrations.java• L107-136 src/…/RegistrationState.java• L3-26

Resource-group state

Resource groups extend the directory scope below a subscription. They are keyed by subscription and group name without case, and they carry the location, tags, manager, and provisioning state that ARM resource services expose. Resource services can create a group as part of a child resource write when the selected parity behavior allows it.

Resource-group state is memory-only by default. When Azure-style resource-group semantics or strict resource-group behavior is enabled, groups use the directory storage store and survive according to the selected storage mode. Group deletion also coordinates with writes under the group so a delete does not leave an in-flight child write outside the group lifecycle. ResourceGroups and ResourceGroup define this state.

References: src/…/ResourceGroups.java• L26-35 src/…/ResourceGroups.java• L56-71 src/…/ResourceGroups.java• L90-183 src/…/ResourceGroups.java• L194-237 src/…/ResourceGroup.java• L9-23

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep per-cloud default locations aligned with the catalog's canonical location names and with the location rules used by ARM resource writes.
  • Keep the cloud catalog suffix set aligned with host routing, cloud metadata responses, and service URLs returned by handlers.
  • Keep the host-routed flag for each suffix aligned with the service routes that accept host-based dispatch.
  • Keep default tenant and subscription IDs aligned with Entra defaults, ARM defaults, managed identity scopes, and seeded response data.
  • Keep subscription tenant references valid when configured tenants are renamed or removed.
  • Keep parity switches aligned with unknown-subscription handling, provider registration defaults, and resource-group persistence behavior.
  • Keep directory storage keys and case-folding rules stable so persisted first-use and provider-registration state remains readable.
  • Keep startup reload rules aligned with the contract for removing stale seeded or configured entries.
  • Keep scope precedence aligned with ARM paths, Entra tenant paths, service DNS suffixes, catalog hosts, and the default cloud.
  • Keep token-tenant hint behavior aligned with tenant-scoping and strict-token settings when changing unknown-subscription ownership.
  • Keep each cloud's Azure AI Search suffix aligned with Search service host routing and generated service URLs.

Important failure modes

TriggerConsequenceGuard
Unknown configured cloud name or per-cloud default locationStartup fails before requests are servedCloudDefaults validates cloud names and locations against CloudCatalog
Unknown configured cloud name in directory settingsStartup fails before the directory is builtDirectorySeed validates names against CloudCatalog
Missing or duplicate tenant or subscription IDStartup fails or the seed cannot be builtSeed validation requires non-blank IDs and rejects duplicates
Subscription points to an unconfigured tenantStartup failsSubscription seed validation checks tenant ownership
Unknown subscription under strict behaviorARM returns SubscriptionNotFound instead of registering itstrict-subscriptions parity rule
Resource provider namespace is untouched under strict provider behaviorProvider operations see NotRegistered until an explicit register actionProviderRegistrations uses strictProviders as the default state
Resource request targets a missing group under strict behaviorARM returns ResourceGroupNotFoundstrict-resource-groups parity rule
Malformed, incomplete, or ambiguous bundled cloud dataStartup fails rather than serving incomplete endpoint or suffix dataCloudCatalog validates required fields, suffix coverage, and unique cloud and suffix ownership
Persisted subscription refers to a removed tenantThe subscription could report an owner that tenant listing does not containReload moves it to the current default tenant
Token tenant scoping is disabledAn unknown subscription uses the default tenant instead of a caller token tenantEnable tenant scoping or strict token checks when token tenant hints must affect scope resolution
A request relies on a lower-priority cloud signalThe resolver records the wrong cloud or scope for the requestARM subscription paths and tenant paths take precedence over host and default signals
An Azure AI Search host uses a missing or incorrect cloud suffixSearch requests or returned service URLs target the wrong hostKeep the Search suffix in each applicable cloud profile

Key files

FileWhy to read it
src/…/EmulatorConfig.javaDefines cloud, directory, and parity configuration inputs.
src/…/CloudCatalog.javaShows cloud lookup, DNS suffix matching, Azure host recognition, location normalization, and catalog validation.
src/…/CloudDefaults.javaShows how configured and catalog default locations are selected and checked.
src/…/CloudStartupValidator.javaShows the startup check and cloud summary that run before request handling.
src/…/CloudSuffix.javaShows which service suffixes support host-based routing and which only build response hosts.
src/…/CloudMetadata.javaShows how cloud discovery responses expose emulator endpoints.
src/…/ScopeResolver.javaShows how request signals, optional token tenant hints, and directory ownership become cloud and ARM scope.
src/…/ScopeContext.javaDefines the scope carried through request handling.
src/…/DirectorySeed.javaBuilds and validates the initial tenant and subscription state.
src/…/AzureDirectory.javaOwns directory lookup, first-use registration, persistence, and reload.
src/…/ProviderRegistrations.javaOwns provider namespace registration defaults, changes, and persistence.
src/…/ResourceGroups.javaOwns resource-group lifecycle, write/delete coordination, and optional persistence.
src/…/clouds.jsonSupplies the bundled cloud profiles, locations, and service DNS data, including Azure AI Search suffixes for public, Government, and China clouds.