Skip to content

Make AZD postprovision credential-aware and safely initialize settings and Search #1489

Open

Description

@paullizer

Issue

AZD postprovision can fail on Cosmos accounts with local authentication disabled even when the runner has valid Entra data-plane access. The former key-only probe treated authentication failures as firewall propagation problems and could replace existing network rules with a runner-only rule.

Deployment-time settings writes also need to participate in the shared settings-store publication protocol, and fresh deployments require manual Search-index setup before document search can work.

Steps to Reproduce

  1. Deploy with managed_identity authentication against a Cosmos account with disableLocalAuth enabled.
  2. Run azd up or the postprovision hook from an authorized runner.
  3. Observe the key-based probe fail and the hook attempt an IP-rule update and propagation wait.
  4. In a Redis-enabled app, run the former postconfig writer while other workers update settings; its direct whole-document upsert bypasses coordinated shared-cache publication.
  5. On a deployment without Search indexes, use document search before manually creating the indexes in Admin Settings.

Expected Behavior

Use the selected deployment credential and environment; distinguish authentication and network errors without changing firewall policy. Publish intended settings changes with Cosmos concurrency checks and the existing shared Redis protocol. Create only missing Search indexes from the application schemas, preserving existing indexes and data.

Scope and Related Work

Acceptance Criteria

  • Managed-identity Cosmos checks use the deployment runner's tenant-scoped Entra credential; key mode explicitly checks whether local auth is allowed.
  • Windows and POSIX postprovision never change Cosmos firewall rules or silently fall back from Entra to keys.
  • Hook lookups and role commands use the selected deployment environment/subscription, with actionable failures for missing required outputs.
  • Postconfig consolidates Redis assignments and uses the shared OCC/fenced publication store, preserving concurrent unrelated edits and external-cache settings.
  • Publication failures are not reported as success; active Redis connection migrations are refused rather than performed implicitly.
  • Missing personal/group/public Search indexes are created from app JSON schemas; existing indexes are untouched, and permission/service failures do not trigger creation.
  • Add offline behavioral tests for auth, environment selection, concurrency, publication failures, reruns, index races, and both platform hook paths.
  • Complete PR review and merge into Development.
  • Validate the new hook implementation in Azure using a runner with the documented Cosmos, Redis, and Search data-plane permissions.

Validation

  • 184 focused tests passed; 18 existing return-value warnings.
  • PowerShell/POSIX syntax and offline hook execution tests passed.
  • Broken-access-control, XSS, and whitespace checks passed.
  • Documentation quality: 6/6 passed. Surface coverage: 6/7; generated inventory mismatch also reproduced on unmodified Development and left out of scope.
  • No live cloud resources were changed during implementation/testing of this PR.

Operational Requirements

The runner needs approved network access and service data-plane permissions. Redis publication requires a suitable Redis database access policy; resource Owner alone is not sufficient. The change does not create policy exemptions, open firewalls, or enable local authentication. Active-cache migrations and existing Search schema upgrades remain administrator-managed.

Priority: P1. Assignee: Paul Lizer (@paullizer). Estimated size: M.

Activity

  1. added
    bugSomething isn't working
    security_improvementThis issue results in an improvement to security
    P1Priority 1: urgent, address before P2 work
    on Sep 17, 2026
  2. moved this from Pending Evaluation to In review in Simple Chat Roadmapon Sep 17, 2026
  3. paullizer commented on Sep 30, 2026

    @paullizer
    ContributorAuthor

    Azure validation of the new postprovision flow

    This covers the open item "Validate the new hook implementation in Azure using a runner with the documented Cosmos, Redis, and Search data-plane permissions." It was run on 2026-09-30 against a SimpleChat POC deployment.

    Environment

    • Azure Commercial. Tenant policy disables local auth on Cognitive Services and Cosmos DB, so the deployment uses AUTHENTICATION_TYPE=managed_identity.
    • Azure Managed Redis Balanced_B0 with access keys disabled (Entra ID only), plus Azure AI Search.
    • Branch paullizer-react-v2-ui at 4f77838, deployer 1.0.32. The post-provision files involved (postconfig.py, deployment_configuration.py, deployment_cosmos.py) are identical on Development.
    • User runner, azd 1.23.12, pwsh hook on Windows.

    What worked

    • [1/4] granted, or confirmed, the user runner's Cosmos control-plane and data-plane roles.
    • [3/4] reached Cosmos with the runner's tenant-scoped Entra credential. It used no keys and changed no firewall rules.
    • Search: all three indexes were found and left unchanged (Search indexes created: none (already exist)).
    • Settings were written through the ETag-checked store and published to Azure Managed Redis (Settings saved and verified). The settings revision went up by one, and the settings snapshot was present in the new cache afterwards.
    • After a restart, the app started on the managed cache with its managed identity. There were no shared-settings warnings.

    Problems found (tracked separately)

    I'm leaving the validation checkbox open until #1589 is fixed, because the hook can't report success before then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

P1Priority 1: urgent, address before P2 workbugSomething isn't workingsecurity_improvementThis issue results in an improvement to security

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions