Managed identity support for Azure Managed Applications is currently in preview. Use the 2018-09-01-preview api version to utilize managed identity.
Learn how to configure a managed application to contain a managed identity. A managed identity can be used to allow the customer to grant the managed application access to existing resources. The Azure platform manages the identity and doesn't require you to provision or rotate any secrets. For more about managed identities in Microsoft Entra ID, see Managed identities for Azure resources.
Your application can be granted two types of identities:
A system-assigned managed identity is tied to your application and is deleted if your app is deleted. An app can only have one system-assigned managed identity.
A user-assigned managed identity is a standalone Azure resource that can be assigned to your app. An app can have multiple user-assigned managed identities.
How to use managed identity
Managed identity enables many scenarios for managed applications. Some common scenarios that can be solved are:
Deploying a managed application linked to existing Azure resources. An example is deploying an Azure virtual machine (VM) within the managed application that is attached to an existing network interface.
Granting the managed application and publisher access to Azure resources outside the managed resource group.
Providing an operational identity of managed applications for Activity Log and other services within Azure.
Adding managed identity
Creating a managed application with a managed identity requires another property to be set on the Azure resource. The following example shows a sample identity property:
There are two common ways to create a managed application with identity: createUiDefinition.json and Azure Resource Manager templates. For simple single create scenarios, createUiDefinition should be used to enable managed identity, because it provides a richer experience. However, when dealing with advanced or complex systems that require automated or multiple managed application deployments, templates can be used.
Using createUiDefinition
A managed application can be configured with managed identity through the createUiDefinition.json. In the outputs section, the key managedIdentity can be used to override the identity property of the managed application template. The following sample enables a system-assigned managed identity on the managed application. More complex identity objects can be formed by using createUiDefinition elements to ask the consumer for inputs. These inputs can be used to construct managed applications with user-assigned managed identity.
Marketplace managed application templates are automatically generated for customers going through the Azure portal create experience.
For these scenarios, the managedIdentity output key on the createUiDefinition must be used to enabled identity.
The managed identity can also be enabled through Azure Resource Manager templates. The following sample enables a system-assigned managed identity on the managed application. More complex identity objects can be formed by using Azure Resource Manager template parameters to provide inputs. These inputs can be used to construct managed applications with user-assigned managed identity.
When to use Azure Resource Manager templates for managed identity
The following are some recommendations on when to use Azure Resource Manager templates for enabling managed identity on managed applications.
Managed applications can be programmatically deployed based on a template.
Custom role assignments for the managed identity are needed to provision the managed application.
The managed application doesn't need the Azure portal and Marketplace creation flow.
SystemAssigned template
A basic Azure Resource Manager template that deploys a managed application with system-assigned managed identity.
Once a managed application is granted an identity, it can be granted access to existing Azure resources by creating a role assignment.
To do so, search for and select the name of the managed application or user-assigned managed identity, and then select Access control (IAM). For detailed steps, see Assign Azure roles using the Azure portal.
Linking existing Azure resources
Obs!
A user-assigned managed identity must be configured before deploying the managed application. In addition, linked resource deployment of managed applications is only supported for the Marketplace kind.
Managed identity can also be used to deploy a managed application that requires access to existing resources during its deployment. When the customer provisions the managed application, user-assigned managed identities can be added to provide more authorizations to the mainTemplate deployment.
Authoring the createUiDefinition with a linked resource
When you link the deployment of the managed application to existing resources, both the existing Azure resource and a user-assigned managed identity with the applicable role assignment on that resource must be provided.
A sample createUiDefinition.json that requires two inputs: a network interface resource ID and a user assigned managed identity resource ID.
This createUiDefinition.json generates a create user experience that has two fields. The first field allows the user to enter in the Azure resource ID for the resource being linked to the managed application deployment. The second is for a consumer to enter the user-assigned managed identity Azure resource ID, which has access to the linked Azure resource. The generated experience would look like:
Authoring the mainTemplate with a linked resource
In addition to updating the createUiDefinition, the main template also needs to be updated to accept the passed in linked resource ID. The main template can be updated to accept the new output by adding a new parameter. Since the managedIdentity output overrides the value on the generated managed application template, it isn't passed to the main template and shouldn't be included in the parameters section.
A sample main template that sets the network profile to an existing network interface provided by the createUiDefinition.json.
Consuming the managed application with a linked resource
Once the managed application package is created, the managed application can be consumed through the Azure portal. Before it can be consumed, there are several prerequisite steps.
An instance of the required linked Azure resource must be created.
The App ID URI of the target resource. It also is the aud (audience) claim of the issued token. The default value is "https://management.azure.com/"
userAssignedIdentities
no
The list of user-assigned managed identities to retrieve a token for. If not specified, listTokens returns the token for the system-assigned managed identity.
To allow for managed identity propagation, create a sleep time of 30 seconds.
Since the managed identity is not in the home tenant of the target scope, you must apply a delay between creating the managed identity and assigning the role to allow the managed identity to propagate between tenants. Without this delay, Azure Resource Manager might not recognize this identity when used in the template and fail within a future deployment script.
The delegatedManagedIdentityResourceId property is used to properly assign roles to managed identities across different tenants. This is particularly useful when dealing with managed applications published in the Azure Marketplace, where the publisher and the customer exist in separate tenants. Learn more about delegatedManagedIdentityResourceId.
Продемонстрировать функции идентификатора Microsoft Entra для модернизации решений удостоверений, реализации гибридных решений и реализации управления удостоверениями.
Сведения о назначении ролей Azure путем определения управляемого удостоверения и последующего выбора области и роли на портале Azure с помощью управления доступом на основе ролей Azure (Azure RBAC).