Azure Managed Identities: System and User-Assigned Managed Identities
Tags: azure, managedidentities, cloud
Published: 2023-07-14 16:53:52

## Overview:
Cloud computing requires robust authentication and access management to ensure secure operations. Traditional approaches to managing access credentials have proven cumbersome and prone to security risks. However, the emergence of managed identities has revolutionized authentication within cloud environments.

This blog post provides an overview of system and user-assigned managed identities, two key types of managed identities. System-assigned managed identities are automatically generated at the resource level, while user-assigned managed identities are explicitly created and assigned by developers or administrators.

---


## Why managed Identities:
Managed identities offer several compelling advantages that make them a preferred choice for authentication and access management in cloud environments. Here are some key reasons why managed identities are beneficial:

**1. Simplified Credential Management:** Managed identities eliminate the need to manually manage access credentials, reducing errors and credential leakage risks.

**2. Enhanced Security:** Managed identities remove the need to embed credentials in code, improving security and integrating with existing cloud security features.

**3. Seamless Integration:** Managed identities easily integrate with cloud identity and access management services, simplifying authentication and enabling secure access to other cloud resources.

**4. Fine-Grained Access Control:** Managed identities allow for precise role-based access control, reducing the risk of unauthorized actions.

**5. Scalability and Flexibility:** Managed identities support scalable architectures, automatically provisioning and deprovisioning identities as resources change.

**6. Integration with Third-Party Platforms:** Managed identities enable secure access to external cloud services, facilitating seamless integration with third-party platforms.

---


## System Assigned Managed Identity:

- In Azure, a system-assigned managed identity is a type of managed identity that is automatically created and assigned to an Azure resource during its provisioning process. This type of managed identity is closely associated with the lifecycle of the resource itself.
- When a system-assigned managed identity is enabled for an Azure resource, such as a virtual machine, Azure Function, or Azure App Service, Azure automatically creates an identity and associates it with that specific resource. The identity exists within the Azure Active Directory tenant associated with the subscription.
- The system-assigned managed identity allows the resource to authenticate and access other Azure resources securely without the need for explicit credentials. The identity is automatically managed by Azure, eliminating the need for manual credential management. This simplifies the authentication process and enhances security by removing the risks associated with managing and storing credentials manually.
- System-assigned managed identities integrate seamlessly with Azure’s role-based access control (RBAC) system, allowing fine-grained access control and enabling the resource to perform only the necessary actions based on assigned roles and permissions.
- The lifecycle of a system-assigned managed identity is tied to the resource it is assigned to. If the resource is deleted, the identity associated with it is also deleted, ensuring that the identity is tightly coupled with the resource’s existence.
- System-assigned managed identities in Azure provide a convenient and secure way to authenticate and authorize Azure resources, reducing complexity and enhancing the overall security posture of cloud-based applications and services.

---

## How to enable the system managed identity in Azure portal:
To enable the system-assigned managed identity for an Azure resource, such as a virtual machine or Azure Function, you can follow these general steps:

**1. Azure Portal:** Navigate to the Azure portal at portal.azure.com and sign in to your Azure account.

**2. Select the Resource:** Locate and select the specific Azure resource for which you want to enable the system-assigned managed identity.

**3. Identity Section:** In the left-hand menu of the resource’s blade, locate and select the “Identity” section. This section might be labelled as “Identity” or “Identity Management.”

**4. Enable System-Assigned Identity:** Within the Identity section, look for the option to enable the system-assigned managed identity. It is usually a toggle switch or checkbox. Enable the system-assigned identity for the resource.

**5. Save the Changes:** Once you have enabled the system-assigned identity, save the changes or update the resource configuration.

After completing these steps, Azure will automatically create a managed identity and associate it with the selected resource. The resource can now use this system-assigned managed identity for authentication and access control when interacting with other Azure services.

![enabling system assigned managed identity](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ubh8l16aryypopl8r3tb.png)

---

## User-Assigned Managed Identity:
In Azure, a user-assigned managed identity is a type of managed identity that you can explicitly create and assign to one or more Azure resources. Unlike system-assigned managed identities, user-assigned managed identities are decoupled from the lifecycle of any specific Azure resource and can be assigned to multiple resources.

---

## How to enable the user-assigned managed identity in Azure portal:
To create a user-assigned managed identity in Azure, you can follow these general steps:

1. Sign in to the Azure portal.

2. In the search box, enter Managed Identities. Under Services, select Managed Identities.

3. Select Add, and enter values in the boxes of the Create User Assigned Managed Identity pane.

4. Select Review + create to review the changes.

5. Select Create.

![User-assigned managed identity](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x48hfnr9go6eelcrahc2.png)

Once the user-assigned managed identity is created, you can assign it to the desired Azure resources by following these steps:

**1. Locate the Resource:** Navigate to the specific Azure resource, such as virtual machine or Azure Function, to which you want to assign the user-assigned managed identity.

**2. Identity Section:** In the resource’s blade, find the “Identity” section. It might be labelled as “Identity” or “Identity Management.”

**3. Assign the Managed Identity:** Within the Identity section, go to the user-assigned tab and click on add. Choose the user-assigned managed identity that you created earlier from the available list or search for it.

**4. Save the Changes:** Once you have assigned the user-assigned managed identity to the resource, save the changes or update the resource configuration.