When deploying a marketplace managed app offer into a customer subscription, you can create an identity in the managed resource group associated with the managed application. However, in order for that identity to have any permissions, it must be assigned a role.
When the publisher and customer are in the same tenant, the roleAssignment can be created as expected and the identity has permissions within the managed resource group.
However, when the customer is in a different tenant (and active directory), then I get the following error:
Principal not found in tenant '[PUBLISHER TENANT ID]'. If you are attempting to PUT this role assignment in tenant '[CUSTOMER TENANT ID]' then the delegatedManagedIdentityResourceId property must be specified
Looking into the mentioned delegatedManagedIdentityResourceId
, it gets pretty hairy pretty quickly and I'm not sure that's the path I want to go down or if it would even get me where I need to be, which is to have an identity in the managed resource group which has permissions to do read/write operations within the managed resource group.
Thank you.
For managed applications published in the marketplace, as you are aware the publisher and the customer are present in different tenants.
Now, when the application is deployed by the customer, the intent is that the publisher is the one who will manage the resources within the managed resource group. Because of this any role assignment that happens as part of the template will happen in the PUBLISHER's tenant. So this means that when looking for principals to assign to the role definition, the deployment will only look for principals in the PUBLISHER tenant.
In the cases like yours, where the managed identity is created as part of the template itself, the identity is created in the customers tenant, but if you try to create the role assignment it would fail since it will not find the identity itself in the publishers tenant. To get around this you need to specify the "delegatedManagedIdentityResourceId" property. The value for this should be the resourceId of the resource for which the managed identity is created.