Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NewManagedIdentityCredential returns an error for unsupported ID options #23267

Merged
merged 3 commits into from
Aug 6, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions sdk/azidentity/managed_identity_credential.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ type ManagedIDKind interface {
idKind() managedIdentityIDKind
}

// ClientID is the client ID of a user-assigned managed identity.
// ClientID is the client ID of a user-assigned managed identity. NewManagedIdentityCredential
// returns an error when a ClientID is specified on the following platforms:
//
// - Azure Arc
// - Cloud Shell
// - Service Fabric
type ClientID string

func (ClientID) idKind() managedIdentityIDKind {
Expand All @@ -44,7 +49,13 @@ func (c ClientID) String() string {
return string(c)
}

// ResourceID is the resource ID of a user-assigned managed identity.
// ResourceID is the resource ID of a user-assigned managed identity. NewManagedIdentityCredential
// returns an error when a ResourceID is specified on the following platforms:
//
// - Azure Arc
// - Azure ML
// - Cloud Shell
// - Service Fabric
type ResourceID string

func (ResourceID) idKind() managedIdentityIDKind {
Expand All @@ -60,9 +71,10 @@ func (r ResourceID) String() string {
type ManagedIdentityCredentialOptions struct {
azcore.ClientOptions

// ID is the ID of a managed identity the credential should authenticate. Set this field to use a specific identity
// instead of the hosting environment's default. The value may be the identity's client ID or resource ID, but note that
// some platforms don't accept resource IDs.
// ID of a managed identity the credential should authenticate. Set this field to use a specific identity instead of
// the hosting environment's default. The value may be the identity's client ID or resource ID.
// NewManagedIdentityCredential returns an error when the hosting environment doesn't support user-assigned managed
// identities, or the specified kind of ID.
chlowell marked this conversation as resolved.
Show resolved Hide resolved
ID ManagedIDKind

// dac indicates whether the credential is part of DefaultAzureCredential. When true, and the environment doesn't have
Expand Down