Skip to content

Commit

Permalink
Update managed identity docs (#23404)
Browse files Browse the repository at this point in the history
  • Loading branch information
chlowell authored Sep 5, 2024
1 parent f0caa1e commit 90dcf48
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
23 changes: 19 additions & 4 deletions sdk/azidentity/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,31 @@ func ExampleNewClientCertificateCredential() {
// Output:
}

// This example shows how to specify a user-assigned identity. Note that some hosting environments
// don't support user-assigned identities, and some that do support them accept only a subset of
// their identifiers. See the documentation for [ClientID], [ResourceID], and [ObjectID] for details.
func ExampleNewManagedIdentityCredential_userAssigned() {
// select a user assigned identity with its client ID...
// select a user-assigned identity with its client ID...
clientID := azidentity.ClientID("abcd1234-...")
opts := azidentity.ManagedIdentityCredentialOptions{ID: clientID}
cred, err = azidentity.NewManagedIdentityCredential(&opts)
handleError(err)
if err != nil {
// TODO
}

// ...or its resource ID
// ...or its resource ID...
resourceID := azidentity.ResourceID("/subscriptions/...")
opts = azidentity.ManagedIdentityCredentialOptions{ID: resourceID}
cred, err = azidentity.NewManagedIdentityCredential(&opts)
handleError(err)
if err != nil {
// TODO
}

// ...or its object ID
objectID := azidentity.ObjectID("4321dcba-...")
opts = azidentity.ManagedIdentityCredentialOptions{ID: objectID}
cred, err = azidentity.NewManagedIdentityCredential(&opts)
if err != nil {
// TODO
}
}
7 changes: 4 additions & 3 deletions sdk/azidentity/managed_identity_credential.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,11 @@ type ManagedIdentityCredentialOptions struct {
dac bool
}

// ManagedIdentityCredential authenticates an Azure managed identity in any hosting environment supporting managed identities.
// ManagedIdentityCredential authenticates an [Azure managed identity] in any hosting environment supporting managed identities.
// This credential authenticates a system-assigned identity by default. Use ManagedIdentityCredentialOptions.ID to specify a
// user-assigned identity. See Microsoft Entra ID documentation for more information about managed identities:
// https://learn.microsoft.com/entra/identity/managed-identities-azure-resources/overview
// user-assigned identity.
//
// [Azure managed identity]: https://learn.microsoft.com/entra/identity/managed-identities-azure-resources/overview
type ManagedIdentityCredential struct {
client *confidentialClient
mic *managedIdentityClient
Expand Down

0 comments on commit 90dcf48

Please sign in to comment.