Skip to content

Instantly share code, notes, and snippets.

@unclebean
Last active October 11, 2024 06:20
Show Gist options
  • Select an option

  • Save unclebean/ae6ac6963bbbf444f627c35db0188383 to your computer and use it in GitHub Desktop.

Select an option

Save unclebean/ae6ac6963bbbf444f627c35db0188383 to your computer and use it in GitHub Desktop.
spn vs uami vs sami
| **Feature** | **Service Principal** | **System-Assigned Managed Identity (SAMI)** | **User-Assigned Managed Identity (UAMI)** |
|---------------------------------|--------------------------------------------------------------------|----------------------------------------------------------------------|----------------------------------------------------------------------|
| **Creation** | Created manually in Azure AD by registering an application. | Automatically created and managed by Azure for a resource. | Created manually and assigned to resources as needed. |
| **Assignment to Resources** | Can be assigned roles or permissions to access resources. | Tied to a single Azure resource (VM, App Service, etc.). | Can be shared and assigned to multiple resources. |
| **Lifecycle** | Stays alive until manually deleted. | Deleted automatically when the associated resource is deleted. | Exists independently of any single resource and must be managed. |
| **Credential Management** | Requires handling credentials such as client secrets or certificates. | No credentials are required to be managed by users. | No credentials are required to be managed by users. |
| **Use Case** | Applications or services interacting with Azure resources. | Individual resources needing to authenticate to Azure services securely. | Reusable identity across multiple resources needing secure access. |
When to Use UAMI vs. SAMI vs. Service Principal
Use a Service Principal if your application needs to run outside of Azure or requires non-Azure AD authentication scenarios. You have full control over creating secrets and managing credentials.
Use SAMI when you want Azure to automatically manage the identity for a single resource. For example, if you want a virtual machine to authenticate to Azure Key Vault or Azure Blob Storage, SAMI is ideal because it’s created and rotated automatically.
Use UAMI when you want an identity that can be shared between multiple Azure resources. For example, if multiple applications or services need to share access to the same Key Vault or storage account, UAMI is ideal because it is a persistent identity independent of any single resource.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment