Conversation
Resolve resource-tenant object IDs with the host's principal lookup and share login-based principal type resolution with provisioning. Recognize system-assigned managed identities in login details. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9c24d9e3-50ce-4517-960f-a5813a362002
|
Azure Pipelines: Successfully started running 1 pipeline(s). 21 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Use the generic auth status message when no client ID is configured. Reject empty Graph object IDs in the shared principal resolver so core provisioning and extension callers share the same guarantee. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9c24d9e3-50ce-4517-960f-a5813a362002
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
System-assigned managed identity login can produce malformed Logged in to Azure as () output.
Get a fresh assessment by requesting another Copilot review.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Adds Account.GetCurrentPrincipal for extension-safe, resource-tenant identity resolution.
Changes:
- Adds stable/beta contracts, host implementation, and adapters.
- Centralizes principal-type resolution and managed-identity handling.
- Adds tests and extension documentation.
| File | Description |
|---|---|
docs/guides/creating-an-extension.md |
Guides role-assignment consumers. |
docs/architecture/extension-framework.md |
Updates Account capabilities. |
cli/azd/pkg/output/ux/auth_status.go |
Handles missing client IDs. |
cli/azd/pkg/output/ux/auth_status_test.go |
Tests generic status output. |
cli/azd/pkg/infra/provisioning/current_principal_id_provider.go |
Shares principal-type logic. |
cli/azd/pkg/azureutil/principal.go |
Rejects empty Graph IDs. |
cli/azd/pkg/azureutil/principal_test.go |
Tests Graph fallback results. |
cli/azd/pkg/azdext/contracts/v1beta/account.pb.go |
Adds beta generated messages. |
cli/azd/pkg/azdext/contracts/v1beta/account_grpc.pb.go |
Adds beta generated RPC. |
cli/azd/pkg/azdext/contracts/v1/account.pb.go |
Adds stable generated messages. |
cli/azd/pkg/azdext/contracts/v1/account_grpc.pb.go |
Adds stable generated RPC. |
cli/azd/pkg/azdext/contracts_v1_aliases.go |
Exposes stable SDK aliases. |
cli/azd/pkg/auth/principal.go |
Centralizes principal classification. |
cli/azd/pkg/auth/manager.go |
Recognizes system-assigned identities. |
cli/azd/pkg/auth/manager_test.go |
Tests identity classification. |
cli/azd/internal/grpcserver/versioned_services_generated.go |
Adapts the beta RPC. |
cli/azd/internal/grpcserver/account_service.go |
Implements principal resolution. |
cli/azd/internal/grpcserver/account_service_test.go |
Covers RPC behavior and failures. |
cli/azd/grpc/proto/azd/extensions/v1beta/account.proto |
Defines the beta API. |
cli/azd/grpc/proto/azd/extensions/v1/account.proto |
Defines the stable API. |
cli/azd/docs/extensions/extension-sdk-reference.md |
Documents SDK usage. |
cli/azd/docs/extensions/extension-framework.md |
Documents semantics and compatibility. |
Files not reviewed (6)
- cli/azd/internal/grpcserver/versioned_services_generated.go: Generated file
- cli/azd/pkg/azdext/contracts/v1/account.pb.go: Generated file
- cli/azd/pkg/azdext/contracts/v1/account_grpc.pb.go: Generated file
- cli/azd/pkg/azdext/contracts/v1beta/account.pb.go: Generated file
- cli/azd/pkg/azdext/contracts/v1beta/account_grpc.pb.go: Generated file
- cli/azd/pkg/azdext/contracts_v1_aliases.go: Generated file
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Use the generic success message for empty identities in terminal and JSON login output, preserving populated identity formatting and the event envelope. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9c24d9e3-50ce-4517-960f-a5813a362002
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The additive API is consistently implemented, documented, adapted across contract versions, and thoroughly tested.
Review effort: Balanced
Findings: None
Resolved since last review (1)
Files not reviewed (6)
- cli/azd/internal/grpcserver/versioned_services_generated.go: Generated file
- cli/azd/pkg/azdext/contracts/v1/account.pb.go: Generated file
- cli/azd/pkg/azdext/contracts/v1/account_grpc.pb.go: Generated file
- cli/azd/pkg/azdext/contracts/v1beta/account.pb.go: Generated file
- cli/azd/pkg/azdext/contracts/v1beta/account_grpc.pb.go: Generated file
- cli/azd/pkg/azdext/contracts_v1_aliases.go: Generated file
|
Azure Pipelines: Successfully started running 1 pipeline(s). 22 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|

Fixes #10048
Summary
This PR adds
Account.GetCurrentPrincipalso extensions can obtain the deploying identity's object ID and principal type without decoding access tokens themselves. The request requires a subscription ID and does not depend on an active azd environment.The host resolves the object ID in the subscription's resource tenant. Guest users therefore receive the identity needed for role assignments in that tenant, rather than their home-tenant identity. Principal type comes from azd's login details, not token claim heuristics.
Implementation
The method is additive in both the stable and beta contracts, with regenerated Go bindings, SDK aliases, and beta adapters. The frozen legacy contract remains unchanged.
This provides the host API needed by #10008. Replacing the local parser in
azure.ai.projectsremains a follow-up after the extension can consume an SDK release and require a host release containing this method. Older hosts returnUnimplemented.Testing
Authenticated stable and beta RPC tests cover user, guest-user, and service-principal identities. Focused tests cover recorded login types, both managed-identity modes, invalid requests, cancellation, lookup failures, and Graph fallback.
Targeted Go tests, race detection, the azd build, Go modernization, lint, and spelling checks passed. Protobuf generation, contract tests, Buf lint, and compatibility checks against upstream
mainpassed. Azure calls use mocks; no live Azure deployment was run.