Microsoft Azure (50 Qs)•Part 2: Core Architecture & Implementation (Mid-Level)
What is an Azure Managed Identity (System-Assigned vs. User-Assigned)?
senior LevelCode ExampleSystem Design
In Simple Words: Managed Identities eliminate the need for developers to manage credentials in code:
- Azure automatically provisions an identity in Entra ID and assigns it to your Azure resource (VM, App Service, Function).
- The resource fetches short-lived OAuth tokens from the local Azure instance metadata service (
http://169.254.169.254/metadata/identity/oauth2/token). - System-Assigned: Tied directly to the lifecycle of a single resource; deleted automatically when the resource is deleted.
- User-Assigned: Standalone Azure resource that can be shared across multiple VMs or container instances.
csharp
// C# / .NET 8 using Azure.Identity DefaultAzureCredential:
using Azure.Identity;
using Azure.Security.KeyVault.Secrets;
var client = new SecretClient(
new Uri("https://my-vault.vault.azure.net/"),
new DefaultAzureCredential() // Uses Managed Identity automatically in Azure!
);
KeyVaultSecret secret = await client.GetSecretAsync("DatabasePassword");