Skip to content

[PROTOTYPE][Do Not Merge] External Evaluation with dedicated acquisition pipeline - #51413

Open
Weidong Xu (weidongxu-microsoft) wants to merge 6 commits into
Azure:mainfrom
weidongxu-microsoft:prototype/external-evaluation-dedicated-pipeline-opt-in
Open

Weidong Xu (weidongxu-microsoft) wants to merge 6 commits into
Azure:mainfrom
weidongxu-microsoft:prototype/external-evaluation-dedicated-pipeline-opt-in

Conversation

@weidongxu-microsoft

Copy link
Copy Markdown
Member

Warning

This is a prototype for design review and is not intended to merge as-is.

Summary

Prototype of an opt-in External Evaluation ("Invoke") policy in azure-core-management using a dedicated policy-token acquisition pipeline.

When enabled and an eligible management operation receives 403 RequestDisallowedByPolicy, the policy:

  1. Retains a replayable snapshot of the exact serialized request.
  2. Acquires a policy token through its dedicated authenticated pipeline.
  3. Adds the token to x-ms-policy-external-evaluations and replays once through the management pipeline.

This explores the Java equivalent of the Go dedicated-pipeline pattern, rather than the cloned-continuation approach in #49701.

Usage

StorageManager.configure()
    .withExternalEvaluation()
    .authenticate(credential, profile);

External Evaluation is disabled by default.

Pipeline design

  • The generated manager constructs one acquisition pipeline only when explicitly enabled.
  • The acquisition pipeline reuses the management client's credential, scopes, retry policy, configured user policies, provider policies, logging options, and resolved HttpClient.
  • HttpPipelineBuilder retains ownership of default-client selection. The management pipeline reuses acquisitionPipeline.getHttpClient() so both pipelines share transport and connection pooling.
  • The acquisition pipeline excludes ExternalEvaluationPolicy, preventing recursion.
  • Original and replay requests use the management pipeline continuation; acquisition uses its independent pipeline and call context.
  • Acquisition request and token response body logging are disabled through context.

The generated Storage output demonstrating the required emitter change is isolated in:

weidongxu-microsoft@0089732

Behavior

  • Triggers only when every blocking PolicyViolation contains missingPolicyTokenDetails.shouldDeny=true.
  • Rejects challenges requiring a Change Safety reference.
  • Selects subscription, resource-group, or management-group acquisition routes from the original ARM URL.
  • Uses Policy API version 2026-07-01.
  • Preserves the original serialized body for acquisition and replay, including bodyless operations.
  • Replays after any successful acquisition response containing a non-blank top-level token.
  • Chains acquisition failures beneath the original 403 ManagementException.
  • Prevents reacquisition when the request already contains the policy-token header.

Prototype scope

  • azure-core-management: policy implementation, parsing, and tests.
  • azure-core: context-controlled body-logging suppression for sensitive acquisition payloads.
  • Copied generated Storage sources under azure-core-management/src/test: emitter-output demonstration and E2E coverage.
  • No published azure-resourcemanager-storage, azure-resourcemanager-resources, or generator changes.

The caller-owned authenticate(HttpPipeline, AzureProfile) overload cannot automatically enable this design because an opaque, already-built pipeline does not expose enough configuration to reconstruct the acquisition pipeline.

Validation

  • HttpLoggingPolicyTests: 47 passed.
  • ExternalEvaluationPolicyTests: 19 passed.
  • ExternalEvaluationPolicyE2ETests: 2 passed, covering explicit opt-in and disabled-by-default behavior.

Design issue: #50818

Acquire policy tokens through an injected reusable pipeline while keeping original and replay operations on the management pipeline. Add context-controlled body logging protection and focused sync/async tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 61e77038-c0b1-4068-864f-8ad207209200
Keep the copied generator output as a baseline so the later emitter demonstration is isolated to its own generated-code commit.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 61e77038-c0b1-4068-864f-8ad207209200
Require the copied generated Storage manager to construct and install external evaluation automatically. The test fails until the generated fixture implements the emitter pattern.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 61e77038-c0b1-4068-864f-8ad207209200
Require generated managers to leave external evaluation disabled by default and enable it explicitly through configuration.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 61e77038-c0b1-4068-864f-8ad207209200
Expose explicit external evaluation configuration, construct the acquisition pipeline only when enabled, and reuse its builder-resolved HTTP client for the management pipeline.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 61e77038-c0b1-4068-864f-8ad207209200
Copilot AI balanced review requested due to automatic review settings November 25, 2026 05:52
@azure-sdk-automation

Copy link
Copy Markdown
Contributor

The sdk-api-review-ready label cannot create a review PR for this working PR because its branch is in a fork repository. Prefer a working branch in the registered upstream repository, or reach out to the ARH maintainers for help. Fork reviews are supported through the Azure SDK CLI (azsdk apireview create), but the fork requires its own ARH registration and the review PR is created in the fork rather than the upstream repository.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
33 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new external-dependency marker lacks a catalog entry, causing version-update automation to raise ValueError instead of updating versions.

1 open issue
What changed in this PR

This design-review prototype explores opt-in Azure Policy External Evaluation using a dedicated token-acquisition pipeline, as an alternative to the cloned-continuation design in #49701. It remains disabled by default and is not intended to merge as-is.

Changes:

  • Adds parsing for actionable policy denials and documents the acquisition-and-replay flow.
  • Adds context-controlled body-logging suppression with synchronous and asynchronous tests.
  • Adds generated Storage test fixtures and test configuration to support integration coverage without changing published Storage libraries.
File Description
sdk/​core/​azure-core/​src/​test/​java/​com/​azure/​core/​http/​policy/​HttpLoggingPolicyTests.java Tests body-logging suppression in both execution modes.
sdk/​core/​azure-core/​src/​main/​java/​com/​azure/​core/​http/​policy/​HttpLoggingPolicy.java Adds per-call body-logging suppression.
sdk/​core/​azure-core/​CHANGELOG.md Documents the logging option.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​package-info.java Documents the Storage fixture package.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​ZonePlacementPolicy.java Adds zone-placement values for fixtures.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​VirtualNetworkRule.java Adds virtual-network rule serialization.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​UserAssignedIdentity.java Adds identity response deserialization.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​StorageDataCollaborationPolicyProperties.java Adds data-collaboration settings.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​StorageAccountSkuConversionStatus.java Adds SKU-conversion status modeling.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​StorageAccountMicrosoftEndpoints.java Adds Microsoft-routed endpoint modeling.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​StorageAccountInternetEndpoints.java Adds internet-routed endpoint modeling.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​State.java Adds virtual-network rule states.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​SmbOAuthSettings.java Adds SMB OAuth settings.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​SkuTier.java Adds SKU-tier values.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​SkuName.java Adds storage SKU names.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​SkuConversionStatus.java Adds SKU-conversion states.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​Sku.java Adds SKU request and response modeling.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​ServiceSharedKeyAccessProperties.java Adds shared-key access settings.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​SasPolicy.java Adds SAS expiration policy modeling.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​RoutingPreference.java Adds endpoint-routing preferences.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​RoutingChoice.java Adds routing-choice values.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​ResourceProviders.java Adds the fluent resource-definition entry point.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​ResourceAccessRule.java Adds resource-access rule modeling.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​PublicNetworkAccess.java Adds public-network access values.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​ProvisioningState.java Adds account-provisioning states.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​PrivateLinkServiceConnectionState.java Adds private-link connection status modeling.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​PrivateEndpointServiceConnectionStatus.java Adds private-endpoint approval states.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​PrivateEndpointConnectionProvisioningState.java Adds private-endpoint provisioning states.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​PrivateEndpointConnection.java Adds private-endpoint resource modeling.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​PrivateEndpoint.java Adds private-endpoint identifier modeling.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​PostPlannedFailoverRedundancy.java Adds planned-failover redundancy values.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​PostFailoverRedundancy.java Adds failover redundancy values.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​Placement.java Adds zonal-placement settings.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​package-info.java Documents fixture data models.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​MinimumTlsVersion.java Adds TLS-version values.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​LargeFileSharesState.java Adds large-file-share settings.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​Kind.java Adds storage-account kinds.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​KeyType.java Adds encryption-key type values.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​KeySource.java Adds encryption-key provider values.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​KeyPolicy.java Adds key-expiration policy modeling.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​KeyCreationTime.java Adds key-creation timestamp modeling.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​IpRule.java Adds IP access-rule serialization.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​ImmutableStorageAccount.java Adds account-immutability settings.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​IdentityType.java Adds managed-identity type values.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​GeoReplicationStatus.java Adds geo-replication states.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​GeoPriorityReplicationStatus.java Adds priority-replication settings.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​ExtendedLocationTypes.java Adds extended-location type values.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​ExtendedLocation.java Adds extended-location serialization.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​ExpirationAction.java Adds SAS expiration-action values.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​EncryptionServices.java Adds per-service encryption settings.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​EncryptionService.java Adds individual encryption-service modeling.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​EncryptionIdentity.java Adds encryption-identity serialization.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​DualStackEndpointPreference.java Adds IPv6 endpoint settings.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​DnsEndpointType.java Adds DNS endpoint-type values.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​DirectoryServiceOptions.java Adds directory-authentication options.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​DefaultSharePermission.java Adds default share-permission values.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​DefaultAction.java Adds default network-rule actions.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​CustomDomain.java Adds custom-domain settings.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​Bypass.java Adds network-rule bypass values.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​BlobRestoreStatus.java Adds blob-restore status modeling.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​BlobRestoreRange.java Adds blob-restore range modeling.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​BlobRestoreProgressStatus.java Adds blob-restore progress values.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​BlobRestoreParameters.java Adds blob-restore parameter modeling.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​AllowedCopyScope.java Adds storage-copy scope values.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​ActiveDirectoryPropertiesAccountType.java Adds directory-account type values.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​Action.java Adds access-rule action values.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​AccountStatus.java Adds account-availability states.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​AccountImmutabilityPolicyState.java Adds immutability-policy states.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​models/​AccessTier.java Adds storage access-tier values.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​implementation/​StorageManagementClientBuilder.java Adds fixture client construction.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​implementation/​ResourceProvidersImpl.java Implements fluent account-definition creation.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​implementation/​package-info.java Documents fixture implementations.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​fluent/​StorageManagementClient.java Defines the fixture service-client contract.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​fluent/​ResourceProvidersClient.java Defines account-creation and polling operations.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​fluent/​package-info.java Documents fixture service clients.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​fluent/​models/​PrivateEndpointConnectionProperties.java Adds private-endpoint property serialization.
sdk/​core/​azure-core-management/​src/​test/​java/​com/​azure/​resourcemanager/​storage/​fluent/​models/​package-info.java Documents fixture inner models.
sdk/​core/​azure-core-management/​src/​main/​java/​com/​azure/​core/​management/​implementation/​evaluation/​package-info.java Documents internal evaluation types.
sdk/​core/​azure-core-management/​src/​main/​java/​com/​azure/​core/​management/​implementation/​evaluation/​MissingPolicyTokenDetails.java Parses token requirements and Change Safety flags.
sdk/​core/​azure-core-management/​pom.xml Adds WireMock and module access for tests.
sdk/​core/​azure-core-management/​CHANGELOG.md Documents External Evaluation support.

Review effort: Balanced

Comment thread sdk/core/azure-core-management/pom.xml Resolved
Replace WireMock with the existing mock HTTP response infrastructure and avoid deprecated URL construction.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 61e77038-c0b1-4068-864f-8ad207209200
Copilot AI balanced review requested due to automatic review settings November 25, 2026 06:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The non-mergeable prototype needs human architecture review to resolve dedicated-pipeline integration, sensitive-body logging guarantees, and cross-language Change Safety behavior.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

This branch has not been deployed

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

Labels

Azure.Core azure-core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants